From 082e7d4b98b54eb3669b86d8cd236bad3a8ddbab Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 4 Mar 2011 10:01:23 +0100 Subject: Simplify date2sec() in "utils.c". Signed-off-by: Lukas Fleischer --- src/utils.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/utils.c b/src/utils.c index 7fe6ccd..8988c53 100644 --- a/src/utils.c +++ b/src/utils.c @@ -485,26 +485,21 @@ get_item_min (long date) long date2sec (struct date day, unsigned hour, unsigned min) { - struct tm start, *lt; - time_t tstart, t; - - t = time (NULL); - lt = localtime (&t); - start = *lt; + time_t t = now (); + struct tm start = *(localtime (&t)); - start.tm_mon = day.mm; + start.tm_mon = day.mm - 1; start.tm_mday = day.dd; - start.tm_year = day.yyyy; + start.tm_year = day.yyyy - 1900; start.tm_hour = hour; start.tm_min = min; start.tm_sec = 0; start.tm_isdst = -1; - start.tm_year -= 1900; - start.tm_mon--; - tstart = mktime (&start); - EXIT_IF (tstart == -1, _("failure in mktime")); - return tstart; + t = mktime (&start); + EXIT_IF (t == -1, _("failure in mktime")); + + return t; } /* Return a string containing the hour of a given date in seconds. */ -- cgit v1.2.3-70-g09d2