3 ms·
The full code is static int leap_year(const struct cal_control *ctl, int32_t year) { if (year <= ctl->reform_year) return !(year % 4); retu
by voxic11 1y ago
The full code is
static int leap_year(const struct cal_control *ctl, int32_t year)
{
if (year <= ctl->reform_year)
return !(year % 4);
return ( !(year % 4) && (year % 100) ) || !(year % 400);
}
Where reform_year is the year the Gregorian calendar was adopted in the specific context specified (defaults to 1752 which is the year it was adopted by GB and therefore also the US).
So it does account for Julian dates.
- divbzero 1y agocal doesn’t offer an option to use the 1582 reform date, but looks like it does handle the 1752 adoption in Great Britain correctly: $ cal 9 1752 September 1752 Su Mo Tu We Th Fr Sa 1 2 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
- madcaptenor 1y agoBut `ncal` does offer that option. Here's October 1582 in "Italy", which didn't exist back then: $ ncal -sIT 10 1582 October 1582 Mo 1 18 25 Tu 2 19 26 We 3 20 27 Th 4 21 28 Fr 15 22 29 Sa 16 23 30 Su 17 24 31 France apparently took a couple months to get on board (or maybe just to find out): $ncal -sFR 12 1582 December 1582 Mo 3 20 27 Tu 4 21 28 We 5 22 29 Th 6 23 30 Fr 7 24 31 Sa 1 8 25 Su 2 9 26 `ncal -p` gives a list of the country codes it accepts. (These are current countries so it's a bit ahistorical for, say, Germany.) Sadly they don't implement the weird thing Sweden did in the early 18th century: https://en.wikipedia.org/wiki/Swedish_calendar https://en.wikipedia.org/wiki/Swedish_calendar