Example #1
0
        /// <summary>
        /// Returns an instance of <see cref="DateTimeOffset"/> representing the start of the specified <strong>ISO 8601</strong> <paramref name="year"/> and <paramref name="week"/>.
        /// </summary>
        /// <param name="year">The <strong>ISO 8601</strong> year of the week.</param>
        /// <param name="week">The <strong>ISO 8601</strong> week number.</param>
        /// <param name="timeZone">The time zone to convert the <see cref="DateTimeOffset"/> value to.</param>
        /// <returns>An instance of <see cref="DateTimeOffset"/>.</returns>
        public static DateTimeOffset FromWeekNumber(int year, int week, TimeZoneInfo timeZone)
        {
            // Must have a time zone
            if (timeZone == null)
            {
                throw new ArgumentNullException(nameof(timeZone));
            }

            // Get the start of the week
            DateTimeOffset time = FromWeekNumber(year, week, timeZone.BaseUtcOffset);

            // Adjust to the specified time zone
            time = TimeUtils.AdjustForTimeZoneAndDaylightSavings(time, timeZone);

            return(time);
        }