Week support in date classes

  • Thread starter Thread starter JH
  • Start date Start date
J

JH

Why there is not full week support in DateTime classes
in .NET. For instance windows`s normal calendar control
knows how to show week numbers, but you can`t ask that
from DateTime class.

Also here in Finland first week in year can be week 52,
week 53 or week 1. Also last week of the year can be any
of those. So there can be two "week 1"`s in same year
(they can be distinquished by using month number).

DateTime dtDate = DateTime::CurrentDate;
int iWeek = dtDate.WeekNumber
 
JH said:
Why there is not full week support in DateTime classes
in .NET. For instance windows`s normal calendar control
knows how to show week numbers, but you can`t ask that
from DateTime class.

Also here in Finland first week in year can be week 52,
week 53 or week 1. Also last week of the year can be any
of those. So there can be two "week 1"`s in same year
(they can be distinquished by using month number).

DateTime dtDate = DateTime::CurrentDate;
int iWeek = dtDate.WeekNumber

Look at Calendar.GetWeekOfYear, which addresses both of these issues.
 
Back
Top