Skip to content

Commit 7ed2afa

Browse files
committed
Allow for years after 2106
1 parent a6d6405 commit 7ed2afa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/generic/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static really_inline int32_t parse_time(
5555
const uint64_t min = (d[10] * 10) + d[11];
5656
const uint64_t sec = (d[12] * 10) + d[13];
5757

58-
if (year < 1970 || year > 2106)
58+
if (year < 1970)
5959
SYNTAX_ERROR(parser, "Invalid %s in %s", NAME(field), NAME(type));
6060

6161
uint64_t leap_year = is_leap_year(year);

src/westmere/time.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static bool sse_parse_time(const char *date_string, uint32_t *time_in_second) {
9494
uint64_t dy = (uint64_t)_mm_extract_epi8(v, 6) - 1;
9595

9696
bool is_leap_yr = (bool)is_leap_year((uint32_t)yr);
97-
if(mo > 11) { return false; } // unlikely branch
97+
if(yr < 1970 || mo > 11) { return false; } // unlikely branch
9898
if (dy > (uint64_t)mdays_minus_one[mo]) { // unlikely branch
9999
if (mo == 1 && is_leap_yr) {
100100
if (dy != 29 - 1) {
@@ -112,7 +112,7 @@ static bool sse_parse_time(const char *date_string, uint32_t *time_in_second) {
112112
days += dy;
113113
uint64_t time_in_second64 = seconds + days * 60 * 60 * 24;
114114
*time_in_second = (uint32_t)time_in_second64;
115-
return time_in_second64 == (uint32_t)time_in_second64;
115+
return true;
116116
}
117117

118118
nonnull_all

tests/time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void time_stamp_syntax(void **state)
5959
// year before 1970
6060
{ "19690101010101", 0, ZONE_SYNTAX_ERROR },
6161
// year after 2106
62-
{ "21070101010101", 0, ZONE_SYNTAX_ERROR },
62+
{ "21070101010101", 28319565, ZONE_SUCCESS },
6363
// month 0
6464
{ "20230001010101", 0, ZONE_SYNTAX_ERROR },
6565
// month 13

0 commit comments

Comments
 (0)