c#对时间的处理(待添加)
来源:互联网 发布:手机扫描编辑软件 编辑:程序博客网 时间:2024/06/16 07:42
1:返回在一定的时间段中某个星期数的时间集合
/// <summary> /// 返回在一个范围中所选取的星期1-7的年月日的集合 /// </summary> /// <param name="StartDate">开始日期</param> /// <param name="EndDate">结束的日期</param> /// <param name="week">需要提取的星期1-7数组:如(1,2)</param> /// <returns>返回时间的集合</returns> public List<string> getDateOfWeek(DateTime StartDate, DateTime EndDate, string[] week) { int weekFirst = Convert.ToInt32(StartDate.DayOfWeek);//开始日期第一天是星期几 int startMonth = StartDate.Month; int startDay = StartDate.Day; int startYear = StartDate.Year; int maxMonthDays = DateTime.DaysInMonth(startYear, startMonth); DateTime outputDate = DateTime.Parse(startYear + "-" + startMonth + "-" + startDay); List<string> alldate = new List<string>(); for (int i = 0; i < week.Length; i++) { startMonth = StartDate.Month; startDay = StartDate.Day; startYear = StartDate.Year; outputDate = StartDate; if (weekFirst == int.Parse(week[i])) { outputDate = DateTime.Parse(startYear + "-" + startMonth + "-" + startDay); alldate.Add(outputDate.ToString()); } if (weekFirst < int.Parse(week[i])) { startDay = StartDate.Day + (int.Parse(week[i]) - weekFirst); outputDate = DateTime.Parse(startYear + "-" + startMonth + "-" + startDay); alldate.Add(outputDate.ToString()); } if (weekFirst > int.Parse(week[i])) { startDay = StartDate.Day - (weekFirst - int.Parse(week[i])); } while (outputDate < EndDate) { maxMonthDays = DateTime.DaysInMonth(startYear, startMonth); startDay = startDay + 7; if (startDay > maxMonthDays) { startDay = startDay - maxMonthDays; startMonth++; } if (startMonth > 12) { startMonth = 1; startYear++; } outputDate = DateTime.Parse(startYear + "-" + startMonth + "-" + startDay); if (outputDate < EndDate) { alldate.Add(outputDate.ToString()); } } } return alldate; }
阅读全文
0 0
- c#对时间的处理(待添加)
- 对时间的处理
- c# 对时间的处理 判断日期差
- C#中获取当前时间,及处理时间(对时间进行加减)
- IOS对时间的操作大全 待更新
- PHP 对时间的处理
- javaScript对时间的处理
- ruby对时间的处理
- 各种时间转换 ,对时间的处理
- C#有关时间的处理
- C# 时间函数的处理
- C# 时间格式的处理
- 关于C#的时间处理
- 对HashMap的了解(待完善)
- C#对异常的处理
- C#对char[]的处理
- 笔记(待添加)
- 判别分析(待添加)
- 数组、链表、堆栈和队列学习
- jQuery 显示隐藏
- pytorch实践中module 'torch' has no attribute 'form_numpy'问题的解决
- 使用RMAN方式定期清理oracle日志
- 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem(最长非减子序列+思路)
- c#对时间的处理(待添加)
- eclise 部署web工程报 There are no resources that can be added or removed from the server. 解决办法
- 存储管理方法详解
- 【数据库设计】概念设计-数据库ER图基础概念
- RxJava+RxAndroid+OKHTTP实现get post 以及下载图片功能
- Frequent Subsets Problem 进制运算 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛
- 暗通道去雾算法 python实现
- kami
- LeetCode--Edit Distance