Week of Year C# Datetime

后端 未结 6 927
情深已故
情深已故 2020-12-20 15:37

I have following code to get the weeknumber of the year given in the DateTime object Time

    public static int WeeksInYear(DateTime date)
    {
        Grego         


        
6条回答
  •  礼貌的吻别
    2020-12-20 16:11

    public static int WeeksInYear(DateTime date)
    {
        GregorianCalendar cal = new GregorianCalendar(GregorianCalendarTypes.Localized);
        return cal.GetWeekOfYear(date, CalendarWeekRule.FirstDay, DayOfWeek.Monday);
    

    I think if change CalendarWeekRule.FirstFourDayWeek to CalendarWeekRule.FirstDay then this will work fine.

    I changed this then its working fine.

提交回复
热议问题