惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - Dawnxu

修改的Flash + ASP.NET 拍照程序 AjaxPro在Windows 2000 server下不能正常使用的解决方案 MSN 8.0 邀请函! RAR 命令 新版XNet.SqlHelper 很不错的Windows 控件 Developer Express Inc.NET 鼠标按住任意控件拖动窗口 61条面向对象设计的经验原则 两个WEB程序之间的通信 本人还有50份GMail邀请函,要的请留言! 关于俱乐部活动的个人想法! 操作MS SQL Server 存储过程的类(外加ASP.NET MessageBox类) 修改的一个Title提示 大学毕业了再看你会后悔一辈子的 妙用Asp.Net中的HttpHandler [转载]ASP.NET分页的处理方式 [转载]ASP.NET开发经验积累 WINDOWS2000开机硬盘自动共享 [转载]无组件上传程序ASP.NET版
C#实现的根据年月日计算星期几的函数
Dawnxu · 2005-05-22 · via 博客园 - Dawnxu

算法如下:
基姆拉尔森计算公式
W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7

在公式中d表示日期中的日数,m表示月份数,y表示年数。

注意:在公式中有个与其他公式不同的地方:

把一月和二月看成是上一年的十三月和十四月,例:如果是2004-1-10则换算成:2003-13-10来代入公式计算。

代码如下:

 1 //y-年,m-月,d-日期
 2 string CaculateWeekDay(int y,int m, int d)
 3 {
 4 if(m==1) m=13;
 5 if(m==2) m=14;
 6 int week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7
 7 string weekstr="";
 8 switch(week)
 9 {
10 case 1: weekstr="星期一"break;
11 case 2: weekstr="星期二"break;
12 case 3: weekstr="星期三"break;
13 case 4: weekstr="星期四"break;
14 case 5: weekstr="星期五"break;
15 case 6: weekstr="星期六"break;
16 case 7: weekstr="星期日"break;
17 }
18 
19 return weekstr; 
20 }
21 
22 //调用方法:
23 Label2.Text=CaculateWeekDay(2004,12,9);