diff options
Diffstat (limited to 'src/calendar.c')
-rw-r--r-- | src/calendar.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/calendar.c b/src/calendar.c index e303ab9..8fea79d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -124,13 +124,13 @@ calendar_date_thread (void *arg) tomorrow = (time_t) (get_today () + DAYINSEC); while ((actual = time (NULL)) < tomorrow) - (void)sleep (tomorrow - actual); + sleep (tomorrow - actual); calendar_set_current_date (); calendar_update_panel (&win[CAL]); } - return (void *)0; + return NULL; } /* Launch the calendar date thread. */ @@ -198,7 +198,7 @@ calendar_change_first_day_of_week (void) unsigned calendar_week_begins_on_monday (void) { - return (week_begins_on_monday); + return week_begins_on_monday; } /* Fill in the given variable with the current date. */ @@ -221,14 +221,14 @@ calendar_init_slctd_day (void) struct date * calendar_get_slctd_day (void) { - return (&slctd_day); + return &slctd_day; } /* Returned value represents the selected day in calendar (in seconds) */ long calendar_get_slctd_day_sec (void) { - return (date2sec (slctd_day, 0, 0)); + return date2sec (slctd_day, 0, 0); } static int @@ -236,12 +236,12 @@ calendar_get_wday (struct date *date) { struct tm t; - (void)memset (&t, 0, sizeof (struct tm)); + memset (&t, 0, sizeof (struct tm)); t.tm_mday = date->dd; t.tm_mon = date->mm - 1; t.tm_year = date->yyyy - 1900; - (void)mktime (&t); + mktime (&t); return t.tm_wday; } @@ -249,14 +249,14 @@ calendar_get_wday (struct date *date) static unsigned months_to_days (unsigned month) { - return ((month * 3057 - 3007) / 100); + return (month * 3057 - 3007) / 100; } static long years_to_days (unsigned year) { - return (year * 365L + year / 4 - year / 100 + year / 400); + return year * 365L + year / 4 - year / 100 + year / 400; } static long @@ -270,7 +270,7 @@ ymd_to_scalar (unsigned year, unsigned month, unsigned day) year--; scalar += years_to_days (year); - return (scalar); + return scalar; } /* @@ -287,11 +287,11 @@ date_change (struct tm *date, int delta_month, int delta_day) t.tm_mday += delta_day; if (mktime (&t) == -1) - return (1); + return 1; else { *date = t; - return (0); + return 0; } } @@ -495,12 +495,12 @@ draw_weekly_view (struct window *cwin, struct date *current_day, else days_to_remove = c_wday == 0 ? WEEKINDAYS - 1 : c_wday - 1; - (void)memset (&t, 0, sizeof (struct tm)); + memset (&t, 0, sizeof (struct tm)); t.tm_mday = slctd_day.dd; t.tm_mon = slctd_day.mm - 1; t.tm_year = slctd_day.yyyy - 1900; - (void)mktime (&t); - (void)date_change (&t, 0, -days_to_remove); + mktime (&t); + date_change (&t, 0, -days_to_remove); /* Print the week number. */ weeknum = ISO8601weeknum (&t); @@ -572,7 +572,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day, } /* get next day */ - (void)date_change (&t, 0, 1); + date_change (&t, 0, 1); } /* Draw marks to indicate midday on the sides of the calendar. */ @@ -636,7 +636,7 @@ calendar_change_day (int datefmt) while (wrong_day) { - (void)snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt)); + snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt)); status_mesg (_(outstr), ""); if (getstring (win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC) return; @@ -659,7 +659,7 @@ calendar_change_day (int datefmt) if (wrong_day) { status_mesg (mesg_line1, mesg_line2); - (void)wgetch (win[STA].p); + wgetch (win[STA].p); } } } @@ -668,12 +668,12 @@ calendar_change_day (int datefmt) } void -calendar_move (enum move move) +calendar_move (enum move move, int count) { int ret, days_to_remove, days_to_add; struct tm t; - (void)memset (&t, 0, sizeof (struct tm)); + memset (&t, 0, sizeof (struct tm)); t.tm_mday = slctd_day.dd; t.tm_mon = slctd_day.mm - 1; t.tm_year = slctd_day.yyyy - 1900; @@ -684,42 +684,44 @@ calendar_move (enum move move) if ((slctd_day.dd <= 7) && (slctd_day.mm == 1) && (slctd_day.yyyy == 1902)) return; - ret = date_change (&t, 0, -WEEKINDAYS); + ret = date_change (&t, 0, -count * WEEKINDAYS); break; case DOWN: if ((slctd_day.dd > days[slctd_day.mm - 1] - 7) && (slctd_day.mm == 12) && (slctd_day.yyyy == 2037)) return; - ret = date_change (&t, 0, WEEKINDAYS); + ret = date_change (&t, 0, count * WEEKINDAYS); break; case LEFT: if ((slctd_day.dd == 1) && (slctd_day.mm == 1) && (slctd_day.yyyy == 1902)) return; - ret = date_change (&t, 0, -1); + ret = date_change (&t, 0, -count); break; case RIGHT: if ((slctd_day.dd == 31) && (slctd_day.mm == 12) && (slctd_day.yyyy == 2037)) return; - ret = date_change (&t, 0, 1); + ret = date_change (&t, 0, count); break; case WEEK_START: /* Normalize struct tm to get week day number. */ - (void)mktime (&t); + mktime (&t); if (calendar_week_begins_on_monday ()) days_to_remove = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : t.tm_wday - 1); else days_to_remove = ((t.tm_wday == 0) ? 0 : t.tm_wday); - ret = date_change (&t, 0, 0 - days_to_remove); + days_to_remove += (count - 1) * WEEKINDAYS; + ret = date_change (&t, 0, -days_to_remove); break; case WEEK_END: - (void)mktime (&t); + mktime (&t); if (calendar_week_begins_on_monday ()) days_to_add = ((t.tm_wday == 0) ? 0 : WEEKINDAYS - t.tm_wday); else days_to_add = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : WEEKINDAYS - 1 - t.tm_wday); + days_to_add += (count - 1) * WEEKINDAYS; ret = date_change (&t, 0, days_to_add); break; default: @@ -816,7 +818,7 @@ calendar_end_of_year (void) static double dtor (double deg) { - return (deg * M_PI / 180); + return deg * M_PI / 180; } /* @@ -868,7 +870,7 @@ potm (double days) V = 0.6583 * sin (dtor (2 * (lprime - LambdaSol))); /* sec 65 #13 */ ldprime = lprime + V; /* sec 65 #14 */ D = ldprime - LambdaSol; /* sec 67 #2 */ - return (50.0 * (1 - cos (dtor (D)))); /* sec 67 #3 */ + return 50.0 * (1 - cos (dtor (D))); /* sec 67 #3 */ } /* @@ -898,7 +900,7 @@ pom (time_t tmpt) for (cnt = GMT->tm_year; cnt < EPOCH; ++cnt) days -= ISLEAP (cnt + TM_YEAR_BASE) ? 366 : 365; - return (potm (days)); + return potm (days); } /* @@ -926,5 +928,5 @@ calendar_get_pom (time_t date) && relative_pom < abs (pom_tomorrow - half)) phase = (pom_tomorrow > pom_today) ? FIRST_QUARTER : LAST_QUARTER; - return (pom_pict[phase]); + return pom_pict[phase]; } |