0

I'm working on a calendar system, and I want all national holidays to be automatically calculated and added. The issue is that over half of them depend on the spring equinox which falls on either the 19th, 20th, or 21st of march.

Does anyone have an idea on how to calculate it? I only need the date, time isn't necessary.

S. L.
  • 31
  • 6
  • interesting question :-) you might want to check the Meeus algorithm(s), see eg here https://stackoverflow.com/questions/704108/how-do-i-compute-equinox-solstice-moments ChatGPT can give you an implementation, too. Not sure if there is a library for it out there... – Pinguin Dirk Jun 15 '23 at 06:35
  • @PinguinDirk thank you! Unfortunately couldn't quite get it to work, but I'll keep trying ^^ – S. L. Jun 15 '23 at 06:54

1 Answers1

1

I've found a formula to get which day in march it is;

round((Y * C1 + C2) - (Y / 4))

where Y is the last two digits of the year (2023 -> 23)

C1 is the constant 0.2422

C2 is the constant 20.646

it seems accurate so far..

S. L.
  • 31
  • 6