Example #1
0
 public Week(int year, int weekNumber)
     : base(StartTimeFromWeek(year, weekNumber),
            TimeSpan.FromDays(weekNumber != 1 ? 7 : DateTimeAdditions.GetDaysInFirstWeek(year)))
 {
     Year   = year;
     Number = weekNumber;
 }
Example #2
0
        static DateTime StartTimeFromWeek(int year, int weekNumber)
        {
            var start = new DateTime(year, 1, 1, 0, 0, 0, 0, DateTimeAdditions.StandardCalendar, DateTimeKind.Utc);

            if (weekNumber > 1)
            {
                start = start.AddDays(DateTimeAdditions.GetDaysInFirstWeek(year));
                weekNumber--;
            }
            return(start.AddDays(7 * (weekNumber - 1)));
        }