C# 适用于Windows Phone Silverlight 8.1的公历
有没有办法通过特定日期的Windows Phone(Silverlight 8.1)获取一年中的周数(以及当月的周数)?当我用C#创建一些东西时,我使用了这段代码,但是我找不到Windows Phone的类C# 适用于Windows Phone Silverlight 8.1的公历,c#,silverlight,windows-phone-8.1,gregorian-calendar,C#,Silverlight,Windows Phone 8.1,Gregorian Calendar,有没有办法通过特定日期的Windows Phone(Silverlight 8.1)获取一年中的周数(以及当月的周数)?当我用C#创建一些东西时,我使用了这段代码,但是我找不到Windows Phone的类GregoriaCalendar。即使我使用System.Globalization添加和类sdhould将被支持,我不能使用它 static class DateTimeExtensions { static GregorianCalendar _gc = new Gregorian
GregoriaCalendar
。即使我使用System.Globalization添加代码>和类sdhould将被支持,我不能使用它
static class DateTimeExtensions
{
static GregorianCalendar _gc = new GregorianCalendar();
public static int GetWeekOfMonth(this DateTime time)
{
DateTime first = new DateTime(time.Year, time.Month, 1);
return time.GetWeekOfYear() - first.GetWeekOfYear() + 1;
}
static int GetWeekOfYear(this DateTime time)
{
return _gc.GetWeekOfYear(time, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
}
}