C# - Gets the calendarweek dependent on the current culture

By , 1/29/2007
(1 ratings)
Gets the calendarweek dependent on the current culture
// using System.Globalization;

/// <summary>
/// Gets the calendarweek.
/// </summary>
/// <param name="datetime">The datetime.</param>
/// <returns>the calendarweek</returns>
private static int GetCalendarweek(DateTime datetime)
{
    CultureInfo culture = CultureInfo.CurrentCulture;
    int calendarweek = culture.Calendar.GetWeekOfYear(datetime, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
    return calendarweek;
}
Tagged with calendarweek, culture, week.

Comments

 

Log in, to comment!