summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 10:01:23 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2011-03-04 10:01:23 +0100
commit082e7d4b98b54eb3669b86d8cd236bad3a8ddbab (patch)
tree75f039566d89752432eed35fb589f8ed39945539 /src/utils.c
parent8b34a0e0fdc2ccd932cd16fe6638e96fbb8e25d4 (diff)
downloadcalcurse-082e7d4b98b54eb3669b86d8cd236bad3a8ddbab.zip
Simplify date2sec() in "utils.c".
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c21
1 files changed, 8 insertions, 13 deletions
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. */