Start by wrapping a small test program around it.
Code:
int main ( ) {
for ( int year = 0 ; year <= 2100 ; year++ ) {
int leap = 42;
long long seconds = __year_to_secs(year, &leap);
printf("year=%d seconds=%lld, leap=%d\n", year, seconds, leap);
}
}
$ gcc -Wall -Wextra -g foo.c
$ ./a.out
year=65 seconds=-157766400, leap=0
year=66 seconds=-126230400, leap=0
year=67 seconds=-94694400, leap=0
year=68 seconds=-63158400, leap=1
year=69 seconds=-31536000, leap=0
year=70 seconds=0, leap=0
year=71 seconds=31536000, leap=0
year=72 seconds=63072000, leap=1
year=73 seconds=94694400, leap=0
year=74 seconds=126230400, leap=0
year=75 seconds=157766400, leap=0
...
year=1900 seconds=57749241600, leap=0
year=1901 seconds=57780777600, leap=0
year=1902 seconds=57812313600, leap=0
year=1903 seconds=57843849600, leap=0
year=1904 seconds=57875385600, leap=1
year=1905 seconds=57907008000, leap=0
year=1906 seconds=57938544000, leap=0
year=1907 seconds=57970080000, leap=0
year=1908 seconds=58001616000, leap=1
year=1909 seconds=58033238400, leap=0
year=1910 seconds=58064774400, leap=0
...
Year 70 seems an odd place to start counting from.
> __year_to_secs
Names beginning with double underscores are reserved identifiers.
Originally Posted by
c99
7.1.3 Reserved identifiers
— All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any use.
— All identifiers that begin with an underscore are always reserved for use as identifiers with file scope in both the ordinary and tag name spaces.
The simple calculation ignores all the calendar meddling through centuries past.
Gregorian calendar - Wikipedia