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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 追忆似水年华

dotNet平台下的SNS软件的比较与选用(一) 对于IM市场的思考 杂谈DNN - 追忆似水年华 - 博客园 点评顾雏军 - 追忆似水年华 - 博客园 我要开始研究DNN了 关于《民工》 张纪中 vs 管虎 呵呵,msn7的端口修改了。 记得有人说过,人生有两大欢乐,一是拥有后可以细细品味,二就是追求之中的备感充实。 install sheild调用外部函数(在dll内) 谁用过 install shield x 呀,我遇到麻烦了. 不好意思 又来问问题了. 忽然想起了刘伶 忽然想起我读书时 写的两句话 用vs制作安装程序的时候 如何获取用户输入的序列号,并进行判定 关于向页面注册javascript的技术 我读《Microsoft .NET框架程序设计(修订版)》------DoItNow的读书笔记7 也谈const VS readonly 关于键盘模拟的问题 我读《Microsoft .NET框架程序设计(修订版)》------DoItNow的读书笔记6 发现了MSDN的两个错误 不知道大家的看法如何
C#实现的根据年月日计算星期几的函数
追忆似水年华 · 2005-01-11 · via 博客园 - 追忆似水年华

这个是我知道最简单的算法了. 决定值得收藏.  不过方法不是我写的,不过还是忍不住 拿出来共同分享.

算法如下: 
基姆拉尔森计算公式
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来代入公式计算。

代码如下:
 //y-年,m-月,d-日期
  string CaculateWeekDay(int y,int m, int d)
  {
  if(m==1) m=13;
  if(m==2) m=14;
        int week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
  string weekstr="";
   switch(week)
   {
    case 1: weekstr="星期一"; break;
    case 2: weekstr="星期二"; break;
    case 3: weekstr="星期三"; break;
    case 4: weekstr="星期四"; break;
    case 5: weekstr="星期五"; break;
    case 6: weekstr="星期六"; break;
    case 7: weekstr="星期日"; break;
   }

          return weekstr;
  }

调用方法:
Label2.Text=CaculateWeekDay(2004,12,9);