Browse Source

Fix #20

set_relative_date was failing if the resulting date was in the previous
day.
Yann Weber 5 years ago
parent
commit
2b63e70596
3 changed files with 3 additions and 2 deletions
  1. 1
    1
      src/include/ttail_init.h
  2. 1
    1
      src/ttail_init.c
  3. 1
    0
      tests/ttail_init_set_date_relative.c

+ 1
- 1
src/include/ttail_init.h View File

@@ -287,7 +287,7 @@ int _ttail_set_date_fmt(ttail_t*, char*, int);
287 287
  *- -#2s
288 288
  *- -#3Month
289 289
  *@param ttail_t ttail instance
290
- *@param char*[2] dates {min,max} both can be NULL
290
+ *@param char* date specifier
291 291
  *@param int c the date id to handle
292 292
  *@return -1 if error 0 else
293 293
  */

+ 1
- 1
src/ttail_init.c View File

@@ -561,7 +561,7 @@ int _ttail_set_date_relative(ttail_t* res, char* date, int c)
561 561
 				{
562 562
 					mod = 1;
563 563
 					value = abs(tm->tm_hour);
564
-					tm->tm_hour = 23 - (value % 24);
564
+					tm->tm_hour = 24 - (value % 24);
565 565
 					value /= 24;
566 566
 					value++;
567 567
 				}

+ 1
- 0
tests/ttail_init_set_date_relative.c View File

@@ -67,6 +67,7 @@ START_TEST (fmt_sec)
67 67
 		{"#-10s", 10}, {"#-142sec", 142}, {"#-4096s", 4096},
68 68
 		{"#-1m", 60}, {"#-10min", 600},
69 69
 		{"#-1h", 3600}, {"#-10h", 36000},
70
+		{"#-2h", 7200}, {"#-12h", 43200},
70 71
 		{"#-1d", 3600*24}, {"#-2day", 3600*24*2},
71 72
 	};
72 73
 

Loading…
Cancel
Save