英文:
Is there a way to calculate / get the Spring Equinox in Typescript?
问题
我正在开发一个日历系统,希望所有国定假日都能自动计算并添加。问题在于其中有一半以上的假日是依赖春分日的,而春分日可能落在3月19日、20日或21日。
有人有办法计算吗?我只需要日期,不需要时间。
英文:
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.
答案1
得分: 1
我找到了一个计算三月的日期的公式:
round((Y * C1 + C2) - (Y / 4))
其中,Y是年份的最后两位(2023 -> 23)
C1是常数0.2422
C2是常数20.646
目前看来,这似乎是准确的。
英文:
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..
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论