Zeller 公式:计算任意一天是星期几
Zeller's Formula:
For the Gregorian calendar, Zeller's Formula is
\[\displaystyle W=\left(\left\lfloor \frac{C}{4} \right\rfloor -2C+Y+\left\lfloor \frac{Y}{4} \right\rfloor +\left\lfloor \frac{26(M+1)}{10} \right\rfloor +D-1\right)\bmod 7. \]
Where
\(W\): the day of week. (\(0 =\) Sunday, \(1 =\) Monday, ..., \(5 =\) Friday, \(6 =\) Saturday)
\(C\): the zero-based century. (\(=\lfloor \text{year}/100\rfloor= \text{century}-1\))
\(Y\): the year of the century. (\(=\begin{cases}\text{year}\bmod 100, & M=3,4,\ldots,12, \\ (\text{year}-1)\bmod 100, & M=13,14.\end{cases} \))
\(M\): the month. (\(3 =\) March, \(4 =\) April, \(5 =\) May, ..., \(14 =\) February)
\(D\): the day of the month.
NOTE: In this formula January and February are counted as months 13 and 14 of the previous year. E.g. if it is 2010/02/02, the formula counts the date as 2009/14/02.
For the day before 1582/10/15, notice that the time period from 1582/10/05 to 1582/10/14 does not exists. So for the day before 1582/10/15, the formula is
\[\displaystyle W=\left(\left\lfloor \frac{C}{4} \right\rfloor -2C+Y+\left\lfloor \frac{Y}{4} \right\rfloor +\left\lfloor \frac{26(M+1)}{10} \right\rfloor +D+3 \right)\bmod 7.\]
最新文章
- 高逼格前端开发工具-FIDDLER
- python2.7到python3代码转换脚本2to3的一些介绍
- Ubuntu 虚拟机空间不足增加空间笔记
- 继承自CCObject的对象成员变量出错或者为空的问题
- Codeforces Round #117 (Div. 2)
- python study - 正则表达式
- F - Tree
- Quartz1.8.5例子(一)
- 编程内功修炼之数据结构—BTree(一)
- MySQL- InnoDB锁机制
- 【转】你必须了解的Session的本质
- 浏览器未安装flash插件,js判断直接去官网安装
- java 线程之concurrent中的常用工具 CyclicBarrier
- Confluence 6 升级中的一些常见问题
- 洛谷P4561 [JXOI2018]排序问题(二分 期望)
- SpringBoot入门(0) HelloWorld的实现与原理分析
- day20 Python 高阶函数,函数,嵌套,闭包 装饰器
- Java设计模式(一)普通工场模式 抽象工场模式
- Python参数类型
- 《廖雪峰 . Git 教程》学习总结
热门文章
- 02:linux常用命令
- Encryption (hard) CodeForces - 958C3 (树状数组)
- linux系统内核优化参数
- 今天给大家分享一下js中常用的基础算法
- python 读excel表操作
- Golang中的匿名函数(闭包)
- maven 学习之路一
- Codeforces Round #581 (Div. 2) C. Anna, Svyatoslav and Maps (Floyd 算法,最短路)
- hive创建分区表
- 关于@wraps(fn)