// Set up DataTable
var dt = new DataTable();
var col1 = new DataColumn("ISOWeekNo", typeof(int));
var col2 = new DataColumn("WeekName", typeof(string));
dt.Columns.AddRange(new[] { col1, col2 });
dt.PrimaryKey = new[] { col1 };
// Start with the first day of this year and check each day until next year.
var day = new DateTime(DateTime.Now.Year, 1, 1);
while (day.Year == DateTime.Now.Year)
{
var weekNum = DateTimeFormatInfo.InvariantInfo.Calendar.GetWeekOfYear(day, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
if (!dt.Rows.Contains(weekNum))
dt.Rows.Add(weekNum, string.Format("{0} to {1}", day.ToString("dd' 'MMM' 'yyyy"), day.AddDays(6).ToString("dd' 'MMM' 'yyyy")));
day = day.AddDays(1);
}
컴파일러는 말합니까? – Burimi
문제는 첫 번째 ISO 8601주는 01.01.2012가 아니라 02.01.2012에 시작된다는 것입니다. http://en.wikipedia.org/wiki/ISO_8601 – dknaack