1 long long __year_to_secs(long long year
, int *is_leap
)
3 if (year
-2ULL <= 136) {
8 if (is_leap
) *is_leap
= 1;
9 } else if (is_leap
) *is_leap
= 0;
10 return 31536000*(y
-70) + 86400*leaps
;
13 int cycles
, centuries
, leaps
, rem
;
15 if (!is_leap
) is_leap
= &(int){0};
16 cycles
= (year
-100) / 400;
17 rem
= (year
-100) % 400;
28 if (rem
>= 300) centuries
= 3, rem
-= 300;
29 else centuries
= 2, rem
-= 200;
31 if (rem
>= 100) centuries
= 1, rem
-= 100;
44 leaps
+= 97*cycles
+ 24*centuries
- *is_leap
;
46 return (year
-100) * 31536000LL + leaps
* 86400LL + 946684800 + 86400;