mailing list of musl libc
 help / color / mirror / code / Atom feed
d215880ac942cf12f1880670b6a902144f901b20 blob 931 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
long long __year_to_secs(long long year, int *is_leap)
{
	if (year-2ULL <= 136) {
		int y = year;
		int leaps = (y-68)>>2;
		if (!((y-68)&3)) {
			leaps--;
			if (is_leap) *is_leap = 1;
		} else if (is_leap) *is_leap = 0;
		return 31536000*(y-70) + 86400*leaps;
	}

	int cycles, centuries, leaps, rem, tmp;

	if (!is_leap) is_leap = &tmp;
	cycles = (year-100) / 400;
	rem = (year-100) % 400;
	if (rem < 0) {
		cycles--;
		rem += 400;
	}
	if (!rem) {
		*is_leap = 1;
		centuries = 0;
		leaps = 0;
	} else {
		if (rem >= 200) {
			if (rem >= 300) centuries = 3, rem -= 300;
			else centuries = 2, rem -= 200;
		} else {
			if (rem >= 100) centuries = 1, rem -= 100;
			else centuries = 0;
		}
		if (!rem) {
			*is_leap = 0;
			leaps = 0;
		} else {
			leaps = rem / 4U;
			rem %= 4U;
			*is_leap = !rem;
		}
	}

	leaps += 97*cycles + 24*centuries - *is_leap;

	return (year-100) * 31536000LL + leaps * 86400LL + 946684800 + 86400;
}
debug log:

solving d215880a ...
found d215880a in https://inbox.vuxu.org/musl/1688401586.hkqjuyrd3s.none@localhost/
found 2824ec6d in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 2824ec6dcc80dc4e328b8aafb5268867b5b67147	src/time/__year_to_secs.c

applying [1/1] https://inbox.vuxu.org/musl/1688401586.hkqjuyrd3s.none@localhost/
diff --git a/src/time/__year_to_secs.c b/src/time/__year_to_secs.c
index 2824ec6d..d215880a 100644

Checking patch src/time/__year_to_secs.c...
Applied patch src/time/__year_to_secs.c cleanly.

index at:
100644 d215880ac942cf12f1880670b6a902144f901b20	src/time/__year_to_secs.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).