获取给定周年、给定月份和日期的开始和结束日期给定的一周
如何在 c# 4.0 中获取给定年份 (int)、给定月份 (int) 和给定周 (int) { example Year : 2011 Month: 07 week: 04 } 的开始和结束日期?提前致谢。
2011 年的开始日期为 07 月,该月的周数为 04。
How can I get the start and end date of a given year (int), given month (int), and given week (int) { example Year : 2011 Month: 07 week: 04 } in c# 4.0? Thanks in advance.
The Start Date of the Year 2011 Month 07 and the week number of the month is 04.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你也可以用
它来弄清楚。这几周将会更加困难。
You could also use
to figure it out. The weeks will be more difficult.
日期时间计算,因为这些有点棘手,通过一些假设我可以想出这个
DateTime calculations as these are a bit tricky, with some assumptions i could come up with this
Google 是您的朋友。
几个月:
您可以在几年内做类似的事情:
并且 week 需要使用 CultureInfo.FirstDay (或任何您想要设置为一周的第一天,在某些国家/地区是星期一,有时是星期日)。
Google is your friend.
Months:
You can do something similar for years:
And week needs to use the CultureInfo.FirstDay (or whatever you want to set as the first day of a week, in some countries it's Monday, sometimes it's Sunday).
不确定,但这就是你想要的吗?
Not sure, but is this what you're after?
假设您从第一周开始:
Assuming you start with week 1: