Browse Source

Bugfix in relative dates calculation

Yann Weber 6 years ago
parent
commit
48280fa6d5
1 changed files with 3 additions and 4 deletions
  1. 3
    4
      src/ttail_init.c

+ 3
- 4
src/ttail_init.c View File

@@ -550,7 +550,6 @@ int _ttail_set_date_relative(ttail_t* res, char* date, int c)
550 550
 					tm->tm_min = 60 - (value % 60);
551 551
 					value /= 60;
552 552
 					value++;
553
-					printf("Value left : %d\n", value);
554 553
 				}
555 554
 				if(!mod)
556 555
 				{
@@ -566,7 +565,7 @@ int _ttail_set_date_relative(ttail_t* res, char* date, int c)
566 565
 				{
567 566
 					mod = 1;
568 567
 					value = abs(tm->tm_hour);
569
-					tm->tm_hour = 24 - (value % 24);
568
+					tm->tm_hour = 23 - (value % 24);
570 569
 					value /= 24;
571 570
 					value++;
572 571
 				}
@@ -580,7 +579,7 @@ int _ttail_set_date_relative(ttail_t* res, char* date, int c)
580 579
 			{
581 580
 				mod = 0;
582 581
 				tm->tm_mday -= value;
583
-				if(tm->tm_mday < 0)
582
+				if(tm->tm_mday <= 0)
584 583
 				{
585 584
 					mod = 1;
586 585
 					value = abs(tm->tm_mday);
@@ -594,7 +593,7 @@ int _ttail_set_date_relative(ttail_t* res, char* date, int c)
594 593
 				}
595 594
 			}
596 595
 		case 'M':
597
-			if(*(unit+1) == '\0' || !strcmp(unit, "Month"))
596
+			if(mod || *(unit+1) == '\0' || !strcmp(unit, "Month"))
598 597
 			{
599 598
 				mod = 0;
600 599
 				tm->tm_mon -= value;

Loading…
Cancel
Save