C# 计算一个月内的周数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2201650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:21:13  来源:igfitidea点击:

Calculate week number within month

c#culture

提问by Program.X

Possible Duplicate:
Calculate week of month in .NET

可能的重复:
在 .NET 中计算月份中的一周

I need to calculate the week number of a given Date within a month. The reason I embolden month is that all the examples (on here and elsehwere) I come across are based on yearly. Basically, I want to see what week number 14/2/2010 comes in (dd/MM/yyyy format). Given a starting day of Monday, I would expect this to return 2.

我需要计算一个月内给定日期的周数。我鼓励月份的原因是我遇到的所有例子(在这里和其他地方)都是基于年度的。基本上,我想看看 14/2/2010 是哪个星期(dd/MM/yyyy 格式)。鉴于星期一的开始日,我希望这会返回 2。

How aware of Culture do I have to be in this calculation?

在这个计算中,我必须对文化有多少了解?

采纳答案by jason

This is effectively a duplicate of Get Week of Month in .NET. You need to alter the method GetWeekOfYearshown there to account for the fact that you want your weeks to start on Monday.

这实际上是.NETGet Week of Month的重复。您需要更改GetWeekOfYear此处显示的方法,以说明您希望每周从星期一开始这一事实。

This answer intentionally marked Community Wiki.

这个答案特意标记了社区维基。