Re: [PATCH v3] date: detect underflow/overflow when parsing dates with timezone offset
From: Phillip Wood <hidden>
Date: 2024-06-13 13:31:09
From: Phillip Wood <hidden>
Date: 2024-06-13 13:31:09
Hi Karthik On 12/06/2024 10:49, Karthik Nayak wrote:
"darcy via GitGitGadget" [off-list ref] writes:quoted
+ +/* timestamp of 2099-12-31T23:59:59Z, including 32 leap days */ +static const time_t timestamp_max = ((2100L - 1970) * 365 + 32) * 24 * 60 * 60 - 1;Nit: but since we're calculating the number of years here (2100L - 1970), shouldn't we also be calculating the number of leap days instead of hardcoding it?
I'm happy with a hard coded constant for the number of leap days - I think it is probably easier to check that (which I have done) than it would be to check the calculation as I'm not sure off the top of my head if is it safe to do (2100-1970)/4 or whether we need something more complicated. Best Wishes Phillip