pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/gitgitgadget/git/pull/1986/files

"https://github.githubassets.com/assets/primer-primitives-6da842159062d25e.css" /> fix leap year calculation and remove now-unnecessary timestamp limit by lilyanatia · Pull Request #1986 · gitgitgadget/git · GitHub
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ time_t tm_to_time_t(const struct tm *tm)
int month = tm->tm_mon;
int day = tm->tm_mday;

if (year < 0 || year > 129) /* algo only works for 1970-2099 */
if (year < 0) /* algo only works for 1970+ */
return -1;
if (month < 0 || month > 11) /* array bounds */
return -1;
Expand All @@ -33,6 +33,7 @@ time_t tm_to_time_t(const struct tm *tm)
if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_sec < 0)
return -1;
return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24*60*60UL +
(year + 369) / 400 - (year + 69) / 100 +
tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec;
}

Expand Down Expand Up @@ -526,7 +527,7 @@ static int set_date(int year, int month, int day, struct tm *now_tm, time_t now,
return 1;
r->tm_year = now_tm->tm_year;
}
else if (year >= 1970 && year < 2100)
else if (year >= 1970)
r->tm_year = year - 1900;
else if (year > 70 && year < 100)
r->tm_year = year;
Expand Down Expand Up @@ -871,8 +872,8 @@ static int match_object_header_date(const char *date, timestamp_t *timestamp, in
}


/* timestamp of 2099-12-31T23:59:59Z, including 32 leap days */
static const timestamp_t timestamp_max = (((timestamp_t)2100 - 1970) * 365 + 32) * 24 * 60 * 60 - 1;
/* timestamp of max time */
static const timestamp_t timestamp_max = UINTMAX_MAX;

/* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
(i.e. English) day/month names, and it doesn't work correctly with %z. */
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy