星期计算的小问题(一个世纪的基本世界末日)

发布于 2024-11-06 08:54:34 字数 412 浏览 0 评论 0原文

从这个在线计算器:http://homer.freeshell.org/dd.cgi 使用其数据我已经成功编写了一个工作版本,但是它的数据仅限于 1500 到 2600 年。我想修改(并制作一个更好的版本),以便我可以计算任何年份 > 2600.

参考表X,实际上是否有一个公式可以计算所有基准世纪的基准末日 (2600以上)?

我自己尝试过将几个世纪设置得比这个高,例如2700给了我一个基本的世界末日“00”,2800给了“02;”,2900又回到了“00”......

感谢帮助。

From this online calculator: http://homer.freeshell.org/dd.cgi using its data I've successfully written a working version, however its data is limited to years 1500 to 2600. I want to modify (and make a better one) so that I can calculate for any year > 2600.

Referring to Table X, is there actually a formula to calculate the base doomsday for all base centuries (above 2600)?

I've tried working it out myself by putting centuries higher than this e.g. 2700 gave me a base doomsday of '00', 2800 gave '02;, 2900 back to '00' again...

Help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

月朦胧 2024-11-13 08:54:34

据我了解,该页面的“Base Doomsday”只是一个偏移量,以允许四-闰日计算的百年周期。因此,您只需添加四个世纪的块即可将其无限期地扩展到未来。

As I understand it, that page's “Base Doomsday” is just an offset to allow for the four-hundred-year cycle of leap day calculations. So, you can extend it indefinitely into the future simply by adding blocks of four centuries.

挥剑断情 2024-11-13 08:54:34

还有其他计算器可以做到这一点吗?

计算星期几的两种常用方法
给定的日期是世界末日,您正在使用该日期,
泽勒同余

www.merlyn.demon.co.uk 提供
关于日期/时间计算、各种日历的一些非常有趣的信息
系统和重要日期,因为它们与日历/日期计算相关。

Are there any other calculators out there that do this?

Two common methods for calculating the day of the week
given a date are Doomsday, which you are using,
and Zeller's Congruence

www.merlyn.demon.co.uk provides
some really interesting information on date/time calculations, various calendar
systems and significant dates as they relate to calendar/date calculations.

羁〃客ぐ 2024-11-13 08:54:34

此链接中的计算器 http://homer.freeshell.org/dd.cgi 是最好的就为人类干净清晰地解释世界末日算法而言,有一点警告。

如果你输入2/29/1900,它会说一个星期四。嗯,没有 2/29/1900,因为它不是闰年

当然,如果您输入 1/35/2016,它也会为您“垃圾进垃圾出”。

想象一下,一年只有 364 天,那么每个日期的星期几将永远不会年复一年地改变,因为 mod(364,7)==0

但我们一年有 365 天,所以每年这一天向前推进 1,这就是第二项 mod(year, 7) 的由来。

此外,每 4 年有一个闰年,这有助于最后一项 mod(year, 4)

但每 100 年,您减去一个闰年,每 400 年,您添加一个闰年。这就是第一个术语“3,2,0,5”的用武之地。

你看,这都是因为这个闰年和 mod(365,7)==1 业务。

7/11,5to9对记忆Z表有很大帮助。

The calculator at this link http://homer.freeshell.org/dd.cgi is the best in terms of explaining doomsday algorithm cleanly and clearly for human, with one little caveat.

If you input 2/29/1900, it would say it's a Thursday. Well, there is no 2/29/1900, because it's not a leap year.

Of course if your input 1/35/2016, it would "garbage-in-garbage-out" for you as well.

Imagine there are only 364 days in a year, then the day of week for each date will never change year after year, because mod(364,7)==0.

But we have 365 days a year, so the day steps forward 1 each year, that's where the second term mod(year, 7) comes from.

In addition, every 4 year, there is a leap year, which contributes to the last term mod(year, 4).

But every 100 years, you subtract a leap year, and every 400 years, you add one leap year. That's where the first term "3,2,0,5" comes in.

You see, it's all because of this leap year, and mod(365,7)==1 business.

7/11, 5to9 helps to remember table Z greatly.

挽手叙旧 2024-11-13 08:54:34

尝试一下公式:

c = y % 100
centuryanchor = (5 * (c % 4) % 2 + 2) % 7 if y > 1582 else 6 * c % 7

因为它是显式公式。

例如:

  • 如果 c = 19,则 centuryanchor 为 3;
  • 如果 c = 20,则 centuryanchor 为 2;
  • 如果 c = 21,则 centuryanchor 为 0;
  • 如果 c = 22,则 centuryanchor 为 5;
  • 如果 c = 23,则 centuryanchor 为 3;
  • 如果 c = 20,则 centuryanchor 为 2;
  • ETC。

Try the formula:

c = y % 100
centuryanchor = (5 * (c % 4) % 2 + 2) % 7 if y > 1582 else 6 * c % 7

Because it's the explicit formula.

For example:

  • if c = 19 then centuryanchor is 3;
  • if c = 20 then centuryanchor is 2;
  • if c = 21 then centuryanchor is 0;
  • if c = 22 then centuryanchor is 5;
  • if c = 23 then centuryanchor is 3;
  • if c = 20 then centuryanchor is 2;
  • etc.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文