When displaying year-weeknr in TextBox with TextMode=Week
public class DateHelpers
{
public static string GetCurrentWeekNumber()
{
var weeknum = Thread.CurrentThread.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
return DateTime.Now.ToString($"{DateTime.Now.Year}-W{weeknum}");
}
public static string GetCurrentWeekNumber(DateTime dateTime)
{
var weeknum = Thread.CurrentThread.CurrentCulture.Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
return dateTime.ToString($"{dateTime.Year}-W{weeknum}");
}
}