/* * Set up the default amode for a given time of day. That's AMODE_OFF * most of the time, except that if we're between the default reset * time and the next alarm time (and the next alarm time does not * occur on an off-day), it's AMODE_CONFIRM. */ void default_mode(int timeofday, int dayofweek, int date, struct pstate *ps, struct lstate *ls) { int nextalarm, nextreset, nextenabled; ls->amode = AMODE_OFF; /* * Work out the next alarm time and the next reset time, either of * which might be today or tomorrow. Also, decide whether the * alarm is an enabled one (which it might not be due to either an * off-day or an exclusion). */ nextreset = ps->resettime; if (nextreset <= timeofday) nextreset += 86400; nextalarm = defalarmtime(ps, dayofweek, date, &nextenabled); if (nextalarm <= timeofday) nextalarm = defalarmtime(ps, (dayofweek+1) % 7, increment_date(date), &nextenabled) + 86400; if (nextenabled && nextalarm < nextreset) { ls->amode = AMODE_CONFIRM; } ls->amode_default = 1; }
int main(void) { int y, m, d, daylimit; printf("年:"); do { scanf("%d", &y); if (y < 0){ printf("正の値を入力してください:"); } } while (y < 0); printf("月:"); do { scanf("%d", &m); if (m < 1 || m > 12){ printf("1-12を入力してください:"); } } while (m < 1 || m > 12); daylimit = makedaylimit(y, m); printf("日:"); do { scanf("%d", &d); if (d < 1 || d > daylimit){ printf("1-%dを入力してください:", daylimit); } } while (d < 1 || d > daylimit); increment_date(&y, &m, &d); printf("次の日は%d年%d月%d日です", y, m, d); }
//updates the top row with current hours void update_hour(char * top_row, int *hours_ptr, int *day, int *month, int *year, int am_pm_mode) { // Set the maximum hours // TODO: Insert AM/PM int hour_max = 24; // Increment our hours variable (*hours_ptr) = (*hours_ptr) + 1; // See if we have reached our max hours if ((*hours_ptr) == hour_max) { // Update the date increment_date(day, month, year); // Reset hours (*hours_ptr) = 0; } }
void update_time() { //update_timeXPos();//Alten Zeit löschen for(int x = timeXPos; x<128; x++) { for(int y = timeYPos; y<timeYPos+BIG_NUMBER_HEIGHT; y++) { reset_pixel(x,y); } } minute += timeUpdate; timeUpdate = 0; if(minute > 59) { minute = minute % 60; hour++; } if(hour > 23) { hour = 0; increment_date(); } print_time(TIME_TYPE); update_LCD(); }