void Clock::addSec(int qty) { if(qty >= 60) { sec += qty%60; addMin(qty/60); } else sec += qty; if(sec >= 60) { sec -= 60; addMin(1); } }
void Clock::setClock() { mvprintw(1, 80, "Setting clock..."); clrtoeol(); refresh(); int input = 0; while((input = kbinput()) != 10) { switch(input) { case 272: addHr(1); //F8 increases the hours break; case 56: lessHr(1); //8 decreases the hours break; case 273: addMin(1); //F9 increases the minutes break; case 57: lessMin(1); //9 decreases the minutes break; case 274: addSec(1); //F10 increases the minutes break; case 48: lessSec(1); //0 decreases the minutes break; } display(true); } mvprintw(1, 80, "End setting"); clrtoeol(); refresh(); }
TBool Util::DaylightSavingsAppliesL(const TTime& utc) { // This algorithm needs the first day of the week to be monday TDay oldStart; TLocale set; oldStart = set.StartOfWeek(); set.SetStartOfWeek(EMonday); set.Set(); TBuf<9> min; TBuf<9> max; utc.FormatL(min, KDaylightSavingsMinFormat); utc.FormatL(max, KDaylightSavingsMaxFormat); // Get times representing the first/last possible day of this // year that daylight savings time change could change on TTime timeMin; User::LeaveIfError(timeMin.Set(min)); TTime timeMax; User::LeaveIfError(timeMax.Set(max)); // Find the last sunday in the respective months TTimeIntervalDays addMin(6 - timeMin.DayNoInWeek()); TTimeIntervalDays addMax(6 - timeMax.DayNoInWeek()); timeMin += addMin; timeMax += addMax; // The change happens at 1AM. TTimeIntervalHours hour(1); timeMin += hour; timeMax += hour; // Now we know which day the change occurs on. // Compare it to what the UTC is. TBool result = ((timeMin <= utc) && (timeMax > utc)); // reset the first week day set.SetStartOfWeek(oldStart); set.Set(); return result; }
void Clock::snooze() { addMin(10); mvprintw(3, 80, "Snoozing. Will go off again at %d:%d:%d", hr, min, sec); clrtoeol(); }