Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 适用于Windows Phone Silverlight 8.1的公历_C#_Silverlight_Windows Phone 8.1_Gregorian Calendar - Fatal编程技术网

C# 适用于Windows Phone Silverlight 8.1的公历

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

有没有办法通过特定日期的Windows Phone(Silverlight 8.1)获取一年中的周数(以及当月的周数)?当我用C#创建一些东西时,我使用了这段代码,但是我找不到Windows Phone的类
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);
    }
}