Beispiel #1
0
        /// <summary>
        /// Parse the set of strings for a given day (as a RepeatTimePresenter) into
        /// a corresponding TimeSpan.
        /// </summary>
        /// <param name="timePresenter">The RepeatTimePresenter for the given day.</param>
        /// <returns>A TimeSpan parsed from the strings in the RepeatTimePresenter.</returns>
        private TimeSpan parseRepeats(RepeatTimePresenter timePresenter)
        {
            bool   setPm    = (timePresenter.AmPm == "PM");
            string hoursStr = timePresenter.Hours;
            int    hours    = (hoursStr == "12") ? 0 : Int32.Parse(hoursStr);

            hours += setPm ? 12 : 0;
            int mins = Int32.Parse(timePresenter.Mins);

            return(new TimeSpan(hours, mins, 0));
        }
Beispiel #2
0
 /// <summary>
 /// Method to handle setting all strings and checkbox-booleans according to
 /// the existing repeats in an alarm that has been passed in to edit.
 /// </summary>
 /// <param name="alarm">The Alarm eing edited.</param>
 /// <param name="day">The day of the week to check for repeats in the Alarm.</param>
 /// <param name="checkBox">The corresponding ViewModel boolean for this day (as ref).</param>
 /// <param name="timeInfo">The TimeInfo class for this day.</param>
 private void UpdateFromEditAlarm(RepeatingAlarm alarm, DayOfWeek day, ref bool checkBox, RepeatTimePresenter timeInfo)
 {
     if (alarm.RepeatsOn(day))
     {
         checkBox = true;
         TimeSpan span     = alarm.GetRepeatForDay(day);
         int      hoursNum = (span.Hours > 12) ? (span.Hours - 12) : span.Hours;
         if (hoursNum == 0)
         {
             hoursNum = 12;
         }
         string hours = hoursNum.ToString();
         string mins  = span.Minutes.ToString("D2");
         timeInfo.Hours = hours;
         timeInfo.Mins  = mins;
         if (span.Hours >= 12)
         {
             timeInfo.AmPm = "PM";
         }
     }
 }