C#实现的根据年月日计算星期几的函数

c#日期转换为星期几 winfrom利用枚举类型将输入日期转换为星期 立即下载
算法如下:
基姆拉尔森计算公式
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;
  }

调用方法:
Label1.Text=CaculateWeekDay(2004,12,9);
 
在C#页面中把时间转换成星期 在C#页面中把时间转换成星期,在C#页面中把时间转换成星期 立即下载

相关推荐

国际项目投标那些事(三)海外项目招标文件的组成

以一个实际的项目作为例子,是我2020年初投的一个东南亚国家的水厂的竞争性投标。这个投标的招标基于FIDIC yellow book (Design and Build) 合同模板。 海外项目的招标一般是有专门的咨询公司(consulting engineer)写招标文件,有的咨询公司非常专业,对于技术、合同、业绩的要求非常细致。 我这个项目的招标文件共5册 400多页(全英文),附件26册将...

WTSolutions的博客 2004

js返回当前时间年月日格式

function gettime() { var date = new Date(); var year = date.getFullYear(); var moth = date.getMonth()+1; var dates = date.getDate(); var arr = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];

金鱼记忆大师 942

差分信号_差分信号的原理及其在PCB的设计

差分线是 PCB 设计中非常重要的一部分信号线,信号处理要求也是相当严谨,今天为大家介绍下差分信号的原理以及其在 PCB 设计中的处理方法。 什么是差分信号 差分传输是一种信号传输的技术,区别于传统的一根信号线一根地线的做法,差分传输在这两根线上都传输信号,这两个信号的振幅相等,相位相差 180 度,极性相反。在这两根线上传输的信号就是差分...

weixin_31849185的博客 1812

C# 日期轉成周數

如輸入190101則會輸出1901,表示19年的第一周 private string DataCodDateToWeek(string Date) { string YearWeek; //Date 190101 int Year = DGConvert.Int("20" + Date.Substring...

lee_u的博客 991

从S参数矩阵到硬件实现:手把手教你用耦合微带线设计Marchand巴伦

本文详细介绍了使用耦合微带线设计Marchand巴伦的完整流程。从奇偶模理论和S参数矩阵分析入手,结合ADS仿真软件进行参数优化与电磁仿真验证,最终指导PCB布局、制作与实测调试。文章以2.4GHz Wi-Fi前端电路为例,手把手演示了从理论计算到硬件实现的全过程,并分享了关键的工程经验与调试技巧。

weixin_29271263的博客 536

新手工程师必看:搞定EMI传导干扰,从理解差模和共模开始(附实战案例)

本文深入解析EMI传导干扰中的差模与共模问题,为新手工程师提供从诊断到治理的完整方法论。通过实战案例展示如何通过频谱分析、近场探头扫描等技术精准定位干扰源,并分享PCB布局、滤波器设计等系统级解决方案,帮助工程师高效解决传导干扰问题,提升EMC设计能力。

weixin_26757925的博客 470

C#日期类型转化总结【转化,农历,节气,星期】

参考链接:https://blog.youkuaiyun.com/m1m2m3mmm/article/details/123231352。采用拼接连接符的方式进行日期转换。将8位日期字符串转换为日期格式。使用字符串插入函数进行日期转换。将6位字符串转化为日期格式。

混迹自留地 1005

Oracle-OGG trail 文件大小引起的进程异常 OGG-01172

监控OGG目标端进程,其中一个进程异常,状态为 ABENDED,start repa 执行失败。进入OGG报告目录检查运行报告 2015-04-20 09:38:36 ERROR OGG-01172 Discard file (/ogg/oggrm/11.2/dirdat/repa.dsc) exceeded max bytes (2000000000). 总结处理方法,从根本上解决问题。

xdyzgjy的专栏 7956

c# 判断时间是星期几

DateTime date = (DateTime)time;//time='2019-08-03' //获取星期几 string week=GetWeekDes((int)date.DayOfWeek); private string GetWeekDes(int index) { switch (index) { ...

LookingTomorrow的博客 2162

Python 爬虫教程:金融数据定向抓取(银行 + 投资网站数据结构化提取)

在当今数字化时代,金融数据的获取和分析对于投资者、分析师以及金融机构来说至关重要。Python 爬虫技术可以帮助我们高效地从各种网站上抓取金融数据,从而为投资决策、风险评估和市场分析提供支持。本文将详细介绍如何使用 Python 爬虫技术来定向抓取银行和投资网站的数据,并将其结构化提取,以便进一步分析和使用。

u014481728的博客 881

基于STM32F1XX 、HAL库的OPT4001-Q1环境光传感器驱动应用C语言程序设计

OPT4001-Q1 的输出是半对数 的,具有 9 个二进制对数满量程照度范围,每个范围内具有高度线性响应,使得 PicoStar™ 型号的测量能力为 312.5μlux 至 84klux,USON 型号的测量能力为 400µlux 至 107klux。// 禁用中断(示例)

PP_Cottage的博客 461

c# 日期函数

DateTime dt = DateTime.Now;Label1.Text = dt.ToString();//2005-11-5 13:21:25Label2.Text = dt.ToFileTime().ToString();//127756416859912816Label3.Text = dt.ToFileTimeUtc().ToString();//1277567048599...

diyao2772的博客 174

MTK(基础篇)ROM烧录以及分区的作用

本文介绍了MTK芯片设备的刷机流程及关键分区功能。首先通过MTK烧录工具加载ROM文件(包括引导文件和分区表),重点解析了各分区的核心作用:preloader类似BIOS负责硬件初始化;lk作为二级引导程序加载内核;vbmeta验证系统完整性;boot包含Linux内核;dtbo调整硬件配置;modem管理通信功能;tee保护生物识别数据;system/vendor分别存放系统核心和硬件驱动。特别指出preloader、vbmeta等关键分区损坏会导致设备变砖,而recovery分区是重要的救砖入口。全文简

weixin_49303682的博客 443

C#中实现根据年月日计算星期几的函数

有时候,会想在ASP.NET中根据某个日期计算当天是星期几。下面的代码可以进行这种计算。(网上有很多示例代码,可是我看了好多都是错误的。而且都被转载来转载去,流传开了。我在这里就权且算更正一下。呵呵。)string CaculateWeekDay(int y,int m, int d){ if(m==1) {m=13;y--;} if(m==2) {m=14;y--;} int week=(d

::: 移动互联网时代开发者 ::: 4275

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

C#实现的根据年月日计算星期几的函数

 C#实现的根据年月日计算星期几的函数 方案算法如下: 基姆拉尔森计算公式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来代入公式计算

fyydr2005的专栏 711

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C#实现根据年月日计算星期几的函数

简单的方法string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三","星期四", "星期五", "星期六" };Day[Convert.ToInt16(DateTime.Now.DayOfWeek)];   算法如下:基姆拉尔森计算公式W= (d+2*m+3*(m+1)/5+y+y/4-y/

狼迹天涯的专栏 794

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

上一篇: ASP.NET中文件上传下载方法集合
下一篇: 一周学会C#
nothing7
博客等级 码龄21年 1粉丝 26原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值