有办法在Typescript中计算/获取春分吗?

huangapple go评论54阅读模式
英文:

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..

huangapple
  • 本文由 发表于 2023年6月15日 14:23:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76479659.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定