diff options
Diffstat (limited to 'calendar/timeutil.c')
-rw-r--r-- | calendar/timeutil.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/calendar/timeutil.c b/calendar/timeutil.c index acd2b33ee7..c19b394be9 100644 --- a/calendar/timeutil.c +++ b/calendar/timeutil.c @@ -117,3 +117,51 @@ time_add_year (time_t time, int years) } return new_time; } + +time_t +time_day_hour (time_t t, int hour) +{ + struct tm tm; + time_t retval; + + tm = *localtime (&t); + tm.tm_hour = hour; + tm.tm_min = 0; + tm.tm_sec = 0; + + retval = mktime (&tm); + return retval; +} + + +time_t +time_start_of_day (time_t t) +{ + struct tm tm; + time_t retval; + + tm = *localtime (&t); + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + + retval = mktime (&tm); + return retval; +} + +time_t +time_end_of_day (time_t t) +{ + struct tm tm; + time_t retval; + + tm = *localtime (&t); + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_mday++; + + retval = mktime (&tm); + return retval; +} + |