/// <summary> /// <para>获取日期的星期编号</para> /// <para>Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule</para> /// <para>Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day</para> /// </summary> /// <param name="date">Date to get week number</param> /// <returns>Week number or -1 when error</returns> public static int GetWeekNumber(this DateTime date) { return(date.GetWeekNumber(BaseDateTimeExtensions.GetDefaultCalendarRule(), BaseDateTimeExtensions.GetDefaultFirstWeekDay())); }
/// <summary> /// <para>获取日期的星期编号</para> /// <para>Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day</para> /// </summary> /// <param name="date">Date to get week number</param> /// <param name="weekRule">Rule to calculate week number</param> /// <returns>Week number or -1 when error</returns> public static int GetWeekNumber(this DateTime date, CalendarWeekRule weekRule) { return(date.GetWeekNumber(weekRule, BaseDateTimeExtensions.GetDefaultFirstWeekDay())); }