Browse Source

Bugfix in relative dates calculation

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

Loading…
Cancel
Save