sync datetounix fix from sfeed.c: remove undefined behaviour of right shifting a negative value - frontends - front-ends for some sites (experiment)
HTML git clone git://git.codemadness.org/frontends
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 0563dc62349cd62abd39cb40cd626a28620f5839
DIR parent c8e71a9ce9523857678be7445e8f80c5545f9b2c
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 12 May 2026 20:44:19 +0200
sync datetounix fix from sfeed.c: remove undefined behaviour of right shifting a negative value
Diffstat:
M youtube/feed.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
DIR diff --git a/youtube/feed.c b/youtube/feed.c
@@ -292,7 +292,7 @@ string_print_timestamp(String *s)
}
/* Convert time fields. Returns a signed (at least) 64-bit UNIX timestamp.
- Parameters should be passed as they are in a struct tm:
+ Parameters should be passed as they are in a struct tm and in a valid range:
that is: year = year - 1900, month = month - 1. */
static long long
datetounix(long long year, int mon, int day, int hour, int min, int sec)
@@ -308,8 +308,8 @@ datetounix(long long year, int mon, int day, int hour, int min, int sec)
/* optimization: handle common range year 1902 up to and including 2038 */
if (year - 2ULL <= 136) {
/* amount of leap days relative to 1970: every 4 years */
- leaps = (year - 68) >> 2;
- if (!((year - 68) & 3)) {
+ leaps = (year / 4) - 17; /* 17 leap years offset for 1902 - 1970 */
+ if (!(year & 3)) {
leaps--;
is_leap = 1;
} else {