Skip to content

Commit

Permalink
icaltime: Fails to convert time to time_t before epoch
Browse files Browse the repository at this point in the history
The time_t of a time before epoch is a negative number, but the code
considered a negative number as an incorrectly entered time.
  • Loading branch information
mcrha committed Nov 6, 2024
1 parent 68ba4a0 commit 315406a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/test/regression.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,25 +2123,25 @@ void do_test_time(const char *zone)
0);

/* Conversion to time_t around the epoch */
ictt = icaltime_from_string("19700101T000000Z");
ictt = icaltime_from_string("19691231T235958Z");
tt = icaltime_as_timet_with_zone(ictt, utczone);
int_is("convert to time_t EPOCH", tt, 0);
int_is("convert to time_t EPOCH-2", (int)tt, -2);

ictt = icaltime_from_string("19700101T000001Z");
ictt = icaltime_from_string("19691231T235959Z");
tt = icaltime_as_timet_with_zone(ictt, utczone);
int_is("convert to time_t EPOCH+1", tt, 1);
int_is("convert to time_t EPOCH-1", (int)tt, -1);

ictt = icaltime_from_string("19700101T000002Z");
ictt = icaltime_from_string("19700101T000000Z");
tt = icaltime_as_timet_with_zone(ictt, utczone);
int_is("convert to time_t EPOCH+2", tt, 2);
int_is("convert to time_t EPOCH", (int)tt, 0);

ictt = icaltime_from_string("19691231T235959Z");
ictt = icaltime_from_string("19700101T000001Z");
tt = icaltime_as_timet_with_zone(ictt, utczone);
int_is("convert to time_t EPOCH-1", tt, -1);
int_is("convert to time_t EPOCH+1", (int)tt, 1);

ictt = icaltime_from_string("19691231T235958Z");
ictt = icaltime_from_string("19700101T000002Z");
tt = icaltime_as_timet_with_zone(ictt, utczone);
int_is("convert to time_t EPOCH-2", tt, -2);
int_is("convert to time_t EPOCH+2", (int)tt, 2);
}

void test_iterators(void)
Expand Down

0 comments on commit 315406a

Please sign in to comment.