//Checks with local task if a task is due today bool Storage::isToday(Task* task) { if(task->getDeadLine().year == getCurrentYear() && task->getDeadLine().month == getCurrentMonth() && task->getDeadLine().day == getCurrentDay()) { return true; } else { return false; } }
// returns true when current day is a DST start or end day in some of the major locations in the // world currently returns true for start/end dates for the US and EU int isDSTchangeToday() { int y = getCurrentYear(); int m = getCurrentMonth(); int d = getCurrentDay(); return ( (d == 14 - (1+y*5/4) % 7 && m == 3) // US start || (d == 7 - (1+5*y/4) % 7 && m == 11) // US end || (d == 31 - (4+5*y/4) % 7 && m == 3) // EU start || (d == 31 - (1+5*y/4) % 7 && m == 10)); // EU end }
long long int currentUEBT() { // please note, this is milliseconds from epoch and not seconds unsigned int fhour=0,fminute=0,fsecond=0,millisecond=0; RTC_GetTime(&fhour, &fminute, &fsecond, &millisecond); return dateTimeToUEBT(getCurrentYear(), getCurrentMonth(), getCurrentDay(), getCurrentHour(), getCurrentMinute(), getCurrentSecond(), millisecond); }
void currentDateToString(char *buffer, int format) { dateToString(buffer, getCurrentYear(), getCurrentMonth(), getCurrentDay(), format); }
int addTransactionWizard(char* wallet) { Transaction tx; tx.date.year = getCurrentYear(); tx.date.month = getCurrentMonth(); tx.date.day = getCurrentDay(); tx.time.hour = getCurrentHour(); tx.time.minute = getCurrentMinute(); tx.time.second = getCurrentSecond(); strcpy(tx.description, (char*)""); int curstep = 0; while(1) { SetBackGround(0x0A); drawScreenTitle("Add transaction"); // < (first label), SELECT of on date step, and Next or Finish (last label) drawFkeyLabels(curstep>0 ? 0x036F : -1, curstep == 2 ? 0x000F : 0, 0, 0, 0, curstep==4 ? 0x04A4 : 0x04A3); if(curstep == 0) { MenuItem menuitems[5]; menuitems[0].text = (char*)"Debit"; menuitems[1].text = (char*)"Credit"; Menu menu; menu.items=menuitems; menu.type=MENUTYPE_FKEYS; menu.numitems=2; menu.height=2; menu.startY=3; menu.pBaRtR=1; int inloop=1; while(inloop) { // this must be here, inside this loop: SetBackGround(0x0A); drawScreenTitle("Add transaction", "Select type:"); drawFkeyLabels(-1, -1, -1, -1, -1, 0x04A3); int res = doMenu(&menu); if(res == MENU_RETURN_EXIT) return 0; else if(res == KEY_CTRL_F6 || res == MENU_RETURN_SELECTION) { tx.credit = menu.selection == 2; curstep++; break; } } } else if(curstep == 1) { drawScreenTitle(NULL, "Amount:"); char samount[20] = ""; if(tx.amount.val) { currencyToString(samount, &tx.amount); } textInput input; input.charlimit=12; input.acceptF6=1; input.symbols = 0; // allow the decimal separator input.forcetext = 1; input.buffer = (char*)samount; input.type = INPUTTYPE_NUMERIC; while(1) { input.key=0; int res = doTextInput(&input); if (res==INPUT_RETURN_EXIT) return 0; // user aborted else if (res==INPUT_RETURN_CONFIRM) { if(!stringToCurrency(&tx.amount, samount)) { if(!tx.amount.val) { AUX_DisplayErrorMessage(0x4B); } else { curstep++; } break; } else AUX_DisplayErrorMessage(0x43); } else if (res==INPUT_RETURN_KEYCODE && input.key == KEY_CTRL_F1) { curstep--; break; } } } else if(curstep == 2) { drawScreenTitle(NULL, "Date:"); mPrintXY(7, 4, getInputDateFormatHint(), TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK); textInput input; input.x=7; input.width=8; input.charlimit=8; input.acceptF6=1; input.type=INPUTTYPE_DATE; char datebuffer[15]; fillInputDate(&tx.date, datebuffer); input.buffer = (char*)datebuffer; while(1) { input.key=0; int res = doTextInput(&input); if (res==INPUT_RETURN_EXIT) return 0; // user aborted else if (res==INPUT_RETURN_CONFIRM) { int len = strlen(datebuffer); if(len == input.charlimit) { int yr,m,d; stringToDate(datebuffer, &yr, &m, &d); if(isDateValid(yr, m, d)) { tx.date.year = yr; tx.date.month = m; tx.date.day = d; curstep++; break; // continue to next step } else invalidFieldMsg(0); } else invalidFieldMsg(0); } else if (res==INPUT_RETURN_KEYCODE) { if(input.key==KEY_CTRL_F1) { curstep=curstep-1; break; } else if(input.key==KEY_CTRL_F2) { int ey=0, em=0, ed=0; if(!selectDateScreen(&ey, &em, &ed, (char*)"Select transaction date:", NULL, 1)) { tx.date.year = ey; tx.date.month = em; tx.date.day = ed; curstep++; break; // continue to next step } break; //redraw } } } } else if(curstep == 3) { drawScreenTitle(NULL, "Time:"); mPrintXY(8, 4, "HHMMSS", TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK); textInput input; input.x=8; input.width=6; input.charlimit=6; input.acceptF6=1; input.type=INPUTTYPE_TIME; char tbuffer[15]; fillInputTime(&tx.time, tbuffer); input.buffer = (char*)tbuffer; while(1) { input.key=0; int res = doTextInput(&input); if (res==INPUT_RETURN_EXIT) return 0; // user aborted else if (res==INPUT_RETURN_CONFIRM) { if((int)strlen(tbuffer) == input.charlimit) { int h, m, s; stringToTime(tbuffer, &h, &m, &s); if(isTimeValid(h, m, s)) { tx.time.hour = h; tx.time.minute = m; tx.time.second = s; curstep++; break; // continue to next step } else invalidFieldMsg(1); } else invalidFieldMsg(1); } else if (res==INPUT_RETURN_KEYCODE && input.key==KEY_CTRL_F1) { curstep--; break; } } } else if(curstep == 4) { drawScreenTitle(NULL, "Description:"); textInput input; input.charlimit=128; input.acceptF6=1; input.buffer = (char*)tx.description; int inloop = 1; while(inloop) { input.key=0; int res = doTextInput(&input); if (res==INPUT_RETURN_EXIT) return 0; // user aborted else if (res==INPUT_RETURN_CONFIRM) inloop = 0; // all fields complete, continue with transaction adding else if (res==INPUT_RETURN_KEYCODE && input.key == KEY_CTRL_F1) { curstep--; break; } } if(!inloop) break; } } addTransaction(&tx, wallet); return 1; }
//Return true if a task has expired bool Storage::isExpired(Task* task) { int hour = task->getEndTime().hour; if(hour == 24 || hour == 12) { hour-=12; } if(task->getDeadLine().year < getCurrentYear()) { return true; } else if(task->getDeadLine().year == getCurrentYear() && task->getDeadLine().month < getCurrentMonth()) { return true; } else if(task->getDeadLine().year == getCurrentYear() && task->getDeadLine().month == getCurrentMonth() && task->getDeadLine().day < getCurrentDay()) { return true; } else if(task->getDeadLine().year == getCurrentYear() && task->getDeadLine().month == getCurrentMonth() && task->getDeadLine().day == getCurrentDay() && hour < getCurrentTime().hour) { return true; } else if(task->getDeadLine().year == getCurrentYear() && task->getDeadLine().month == getCurrentMonth() && task->getDeadLine().day == getCurrentDay() && hour == getCurrentTime().hour && task->getEndTime().min < getCurrentTime().min) { return true; } else { return false; } }
std::string getDateStampDMY() { return (getCurrentDay() + '-' + getCurrentMonth() + '-' + getCurrentYear()); }