Exemple #1
0
        public void TestTimeZone()
        {
            TimeZoneInfo    tz = TimeZoneUtil.FindTimeZoneById("Eastern Standard Time");
            HolidayCalendar c  = new HolidayCalendar();

            c.TimeZone = tz;

            DateTimeOffset excludedDay = new DateTimeOffset(2012, 11, 4, 0, 0, 0, TimeSpan.Zero);

            c.AddExcludedDate(excludedDay.DateTime);

            // 11/5/2012 12:00:00 AM -04:00  translate into 11/4/2012 11:00:00 PM -05:00 (EST)
            DateTimeOffset date = new DateTimeOffset(2012, 11, 5, 0, 0, 0, TimeSpan.FromHours(-4));

            Assert.IsFalse(c.IsTimeIncluded(date), "date was expected to not be included.");
            Assert.IsTrue(c.IsTimeIncluded(date.AddDays(1)));

            DateTimeOffset expectedNextAvailable = new DateTimeOffset(2012, 11, 5, 0, 0, 0, TimeSpan.FromHours(-5));
            DateTimeOffset actualNextAvailable   = c.GetNextIncludedTimeUtc(date);

            Assert.AreEqual(expectedNextAvailable, actualNextAvailable);
        }