The trailz function is also useful in deciding whether a four digit year is a leap year.
integer:: yyyy, ntz
logical :: cent, leap
ntz = trailz(yyyy)
cent = mod(yyyy,100).eq.0
if(cent)then
leap = ntz > 3 !yrs divisible by 400
else
leap = ntz > 1 ! yrs divisible by 4
endif
This calculation can be used in a day_of_week(yyyy,mm,dd) routine. One would need to insert code to cover the tricky issue that The year before AD 1 is 1 BC, and there was no year 0000, so the question of whether year 0000 was a leap year is moot.
I read a news article about an unfortunate person whose date of birth had been recorded as Feb 29 of a common (not-leap) year.
For your enjoyment/further confusion, the saying of an AI engine on this topic:
" Yes, according to the Julian calendar, the year 1 BC was a leap year. This is because the Julian calendar, introduced by Julius Caesar, stipulated that a leap year should occur every four years, and 1 BC would be the fourth year after the initial introduction of the calendar in 45 BC. However, due to a misunderstanding by Roman priests, the leap day was not consistently applied in the early years, creating some discrepancy in whether 1 BC was actually a leap year in practice.
After Caesar’s death, the Roman priests in charge of the calendar mistakenly added a leap day every three years instead of four.
This error was eventually corrected by Caesar’s successor, Augustus, who adjusted the calendar to skip leap days for a few years to align it with the solar cycle again.
- [
Although the Julian calendar rules would have made 1 BC a leap year, the “leap year error” makes it uncertain whether it was actually observed as such.
In both the proleptic Julian and [Gregorian calendars] 1 BC is considered a leap year.
- As year 0 AD didn’t exist, does that mean 1 BC was a leap year?
Oct 2, 2020 — Unfortunately, he was murdered in 44 BC, and the Roman priests, tasked with managing the calendar, misunderstood the ru…
This is because the Julian calendar, introduced by Julius Caesar, stipulated that a leap year should occur every four years, and 1 BC would be the fourth year after the initial introduction of the calendar in 45 BC. However, due to a misunderstanding by Roman priests, the leap day was not consistently applied in the early years, creating some discrepancy in whether 1 BC was actually a leap year in practice.
In 45 BC, Julius Caesar introduced a new calendar that included leap years (an extra day every four years) to better align the calendar with the Earth’s orbit around the sun.
After Caesar’s death, the Roman priests in charge of the calendar mistakenly added a leap day every three years instead of four.
45 BC, 42 BC, 39 BC, 36 BC, 33 BC, 30 BC, 27 BC, 24 BC, 21 BC, 18 BC, 15 BC, 12 BC, 9 BC, 8 AD, 12 AD were regarded as leap years before the advent of the Gregorian calendar. See AstroPages | Leap Year | Western Washington University for details.