str_time_to_secs was mucking the mday

This commit is contained in:
Jan-Piet Mens
2015-08-22 09:36:33 +02:00
parent 36de931cd2
commit 73bb0f258c
2 changed files with 13 additions and 7 deletions

View File

@@ -29,3 +29,9 @@
*/
#define GURL "http://maps.googleapis.com/maps/api/geocode/json?latlng=%lf,%lf&sensor=false&language=EN"
/*
* How many hours back should `ocat' display data by default
*/
#DEFAULT_HISTORY_HOURS 6

View File

@@ -52,10 +52,6 @@ static int str_time_to_secs(char *s, time_t *secs)
int success = 0;
memset(&tm, 0, sizeof(struct tm));
tm.tm_isdst = 0; /* A negative value for tm_isdst causes
* the mktime() function to attempt to
* divine whether summer time is in
* effect for the specified time. */
for (f = formats; f && *f; f++) {
if (strptime(s, *f, &tm) != NULL) {
success = 1;
@@ -67,8 +63,12 @@ static int str_time_to_secs(char *s, time_t *secs)
if (!success)
return (0);
// tm.tm_mday = tm.tm_hour = 0;
// tm.tm_hour = tm.tm_min = tm.tm_sec = 1;
tm.tm_mday = (tm.tm_mday < 1) ? 1 : tm.tm_mday;
tm.tm_isdst = -1; /* A negative value for tm_isdst causes
* the mktime() function to attempt to
* divine whether summer time is in
* effect for the specified time. */
*secs = mktime(&tm);
printf("str_time_to_secs: %s becomes %04d-%02d-%02d %02d:%02d:%02d\n",
s,
@@ -85,7 +85,7 @@ int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_hi)
time(&now);
if (!time_from || !*time_from) {
*s_lo = now - (60 * 60 * 6);
*s_lo = now - (60 * 60 * DEFAULT_HISTORY_HOURS);
} else {
if (str_time_to_secs(time_from, s_lo) == 0)
return (0);