C# 获取当年的周六周日
public void GetWMDay()
{
List<string> list = new List<string>();
string year = "";
DateTime counYear = Convert.ToDateTime(year + "-01-01"); //
DateTime nestYear = counYear.AddYears(); for (DateTime i = counYear; i < nestYear; i = i.AddDays())
{
if ((int)i.DayOfWeek == )
{ // 周日 to do } list.Add("周日" + i.ToShortDateString());
}
else if ((int)i.DayOfWeek == )
{ //周六 to do }
list.Add("周六" + i.ToShortDateString());
}
} MessageBox.Show("完成");
}
/// <summary>
/// 获得指定年,月 的周六和周日的 年月日
/// </summary>
/// <param name="year"></param>
/// <returns></returns>
public List<DateTime> GetWMDay(int year,int month)
{
List<DateTime> list = new List<DateTime>();
DateTime counYear = Convert.ToDateTime(string.Format("{0}-{1}-01",year,month));
DateTime nestYear = counYear.AddMonths();
for (DateTime i = counYear; i < nestYear; i = i.AddDays())
{
if ((int)i.DayOfWeek == )
{ // 周日 to do } list.Add(i);
}
else if ((int)i.DayOfWeek == )
{ //周六 to do }
list.Add(i);
}
}
return list;
}
C# 获取当年的周六周日的更多相关文章
- C#去掉周六周日的算法
/// <summary> /// 用来获取工作日(不含周六周日) /// </summary> /// <param name="dtSub"> ...
- WPF 自定义Calendar样式(日历样式,周六周日红色显示)
一.WPF日历控件基本样式 通过Blend获取到Calendar需要设置的三个样式CalendarStyle.CalendarButtonStyle.CalendarDayButtonStyle.Ca ...
- 本月周六周日LIST集合
最近项目中有用到本月所有的周六,周日,特此分享一下! 算法思路:写一个循环,条件为本月开始日期.本月截至日期,通过循环获取第一个周六,加一天就是周日,每增加六天就是下一个周六,依次类推,循环到月末 代 ...
- SQL取出 所有周六 周日的日期
SQL取出 所有周六 周日的日期 create table SatSun([id] int identity(1,1),[date] datetime,[weekday] char(6)) go de ...
- JS获取当年当月最后一天日期
<html xmlns="http://www.w3.org/1999/xhtml" > <meta charset="UTF-8"> ...
- PHP获取时间排除周六、周日的两个方法
//方法一: <?php $now = time(); //指定日期用法 $now = strtotime('2014-01-08') ; $day = 3600*24; $total = 12 ...
- sql 获取本周周一和周日
版本1.0(获取周日存在问题,请勿使用,仅用于引以为戒) 存在问题,获取周日的时候,当当前时间正好是周日,会获取下一周的周日,而非本周周日. ,)),) ),, ,)),) 版本2.0 看到版本1.0 ...
- JEECG 深度使用培训班 周六周日公开课(一期班)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/zhangdaiscott/article/details/25411023 广大技术爱好者: ...
- oracle如何获取当年第一月,如今年是2015年,则需获取 201501
当年第一个月 SQL> select to_char(sysdate,'yyyy')||'01' from dual;TO_CHA ------ 201501当前年,月 SQL> sele ...
随机推荐
- ubuntu update时发生错误
The following packages have been kept back解决方案Ubuntu和Debian下更新软件包,在运行 sudo apt-get upgrade 有时会看到如下提示 ...
- [Vue @Component] Dynamic Vue.js Components with the component element
You can dynamically switch between components in a template by using the reserved <component> ...
- ssh2项目整合 struts2.1+hibernate3.3+spring3 基于hibernate注解和struts2注解
项目文件夹结构例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveW9uZ3poaWFu/font/5a6L5L2T/fontsize/400/fi ...
- UIView的层介绍
UIView的层介绍 subview在西安市到屏幕上时,是位于superview上层的. 同一个view的subview时依照增加的顺序显示相应层的.越晚增加的subview显示在越上层,反之也是如此 ...
- C#根据规则生成6位随机码
#region 获得6位优惠码 zhy public static string CreatePromoCode(string code) { if (code == "") { ...
- 【转】 vsftp上传文件出现553 Could not create file解决方法
因工作需要,需要搭建一个ftp服务器,我使用ubuntu 10.04操作系统,下载vsftpdy源代码, 进行了编译,安装,然后按照INSTALL文件,创建了用户等操作. 因为时间比较紧,我采用 ...
- poj 2955 Brackets dp简单题
//poj 2955 //sep9 #include <iostream> using namespace std; char s[128]; int dp[128][128]; int ...
- ORACLE 11G 怎样改动 awr 的保留期限小于8天
ORACLE 11G 怎样改动 awr 的保留期限小于8天 Oracle Database 11g 默认具备一个系统定义的Moving Window Baseline,该基线相应于 AWR 保留 ...
- P1830 轰炸III
P1830 轰炸III 84通过 145提交 题目提供者wanglichao1121 标签模拟矩阵洛谷原创 难度普及/提高- 提交该题 讨论 题解 记录 最新讨论 暂时没有讨论 题目背景 一个大小为N ...
- MCU低功耗设计(三)产品
关键词: 低功耗设计, 无线通信产品, LoRa长距离, Contiki系统, 能耗实时跟踪 引言: 能耗对电池供电的产品来说是一个重大问题.一旦电能耗尽设备将"罢工".在< ...