Exemple #1
0
        public void SystemTimeZone2()
        {
            System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
            Assert.IsNotNull(tzi);

            iCalendar iCal = new iCalendar();
            ITimeZone tz   = iCal.AddTimeZone(tzi);

            Assert.IsNotNull(tz);

            iCalendarSerializer serializer = new iCalendarSerializer();

            serializer.Serialize(iCal, @"Calendars\Serialization\SystemTimeZone2.ics");

            iCalDateTime dt1    = new iCalDateTime(2003, 10, 26, 0, 59, 59, tz.TZID, iCal);
            iCalDateTime dt2    = new iCalDateTime(2003, 10, 26, 1, 0, 0, tz.TZID, iCal);
            TimeSpan     result = dt2 - dt1;

            Assert.AreEqual(TimeSpan.FromHours(1) + TimeSpan.FromSeconds(1), result);

            dt1    = new iCalDateTime(2004, 4, 4, 1, 59, 59, tz.TZID, iCal);
            dt2    = new iCalDateTime(2004, 4, 4, 2, 0, 0, tz.TZID, iCal);
            result = dt2 - dt1;
            Assert.AreEqual(TimeSpan.FromHours(-1) + TimeSpan.FromSeconds(1), result);
        }
Exemple #2
0
        public ITimeZone AddLocalTimeZone(DateTime earliestDateTimeToSupport, bool includeHistoricalData)
        {
            ITimeZone tz = iCalTimeZone.FromLocalTimeZone(earliestDateTimeToSupport, includeHistoricalData);

            this.AddChild(tz);
            return(tz);
        }
 public static void FixTimeZoneDSTRRules (TimeZoneInfo tz, ITimeZone iCalTz)
 {
   var adjustments = tz.GetAdjustmentRules();
   foreach (var tziItems in iCalTz.TimeZoneInfos)
   {
     var matchingAdj = adjustments.FirstOrDefault(a => (a.DateStart.Year == tziItems.Start.Year)) ?? adjustments.FirstOrDefault();
     if (matchingAdj != null)
     {
       if ((matchingAdj.DateEnd.Year != 9999) && !(tziItems.Name.Equals("STANDARD") && matchingAdj == adjustments.Last()))
       {
         tziItems.RecurrenceRules[0].Until =
           DateTime.SpecifyKind(matchingAdj.DateEnd.Date.AddDays(1).Subtract(tz.BaseUtcOffset), DateTimeKind.Utc);
       }
       if (tziItems.Name.Equals("STANDARD"))
       {
         if (!matchingAdj.DaylightTransitionEnd.IsFixedDateRule)
         {
           var startYear = tziItems.Start.Year;
           tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionEnd, startYear);
         }
       }
       else
       {
         if (!matchingAdj.DaylightTransitionStart.IsFixedDateRule)
         {
           var startYear = tziItems.Start.Year;
           tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionStart, startYear);
         }
       }
     }
   }
 }
Exemple #4
0
        public static void FixTimeZoneDSTRRules(TimeZoneInfo tz, ITimeZone iCalTz)
        {
            var adjustments = tz.GetAdjustmentRules();

            foreach (var tziItems in iCalTz.TimeZoneInfos)
            {
                var matchingAdj = adjustments.FirstOrDefault(a => (a.DateStart.Year == tziItems.Start.Year)) ?? adjustments.FirstOrDefault();
                if (matchingAdj != null)
                {
                    if ((matchingAdj.DateEnd.Year != 9999) && !(tziItems.Name.Equals("STANDARD") && matchingAdj == adjustments.Last()))
                    {
                        tziItems.RecurrenceRules[0].Until =
                            DateTime.SpecifyKind(matchingAdj.DateEnd.Date.AddDays(1).Subtract(tz.BaseUtcOffset), DateTimeKind.Utc);
                    }
                    if (tziItems.Name.Equals("STANDARD"))
                    {
                        if (!matchingAdj.DaylightTransitionEnd.IsFixedDateRule)
                        {
                            var startYear = tziItems.Start.Year;
                            tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionEnd, startYear);
                        }
                    }
                    else
                    {
                        if (!matchingAdj.DaylightTransitionStart.IsFixedDateRule)
                        {
                            var startYear = tziItems.Start.Year;
                            tziItems.Start = CalcTransitionStart(matchingAdj.DaylightTransitionStart, startYear);
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds the local system time zone to the iCalendar.
        /// This time zone may then be used in date/time
        /// objects contained in the calendar.
        /// </summary>
        /// <returns>The time zone added to the calendar.</returns>
        public ITimeZone AddLocalTimeZone()
        {
            ITimeZone tz = iCalTimeZone.FromLocalTimeZone();

            this.AddChild(tz);
            return(tz);
        }
Exemple #6
0
        public ITimeZone AddTimeZone(System.TimeZoneInfo tzi, DateTime earliestDateTimeToSupport, bool includeHistoricalData)
        {
            ITimeZone tz = iCalTimeZone.FromSystemTimeZone(tzi, earliestDateTimeToSupport, includeHistoricalData);

            this.AddChild(tz);
            return(tz);
        }
 public LocationController(ILogger <LocationController> logger, IWeather weatherSvc, ITimeZone timeZoneSvc, IElevation elevationSvc)
 {
     _logger       = logger;
     _weatherSvc   = weatherSvc;
     _timeZoneSvc  = timeZoneSvc;
     _elevationSvc = elevationSvc;
 }
        public ITimeZone AddTimeZone(string tzId, DateTime earliestDateTimeToSupport, bool includeHistoricalData)
        {
            ITimeZone tz = VTimeZone.FromTzId(tzId, earliestDateTimeToSupport, includeHistoricalData);

            this.AddChild(tz);
            return(tz);
        }
        public ITimeZone AddTimeZone(string tzId)
        {
            ITimeZone tz = VTimeZone.FromTzId(tzId);

            this.AddChild(tz);
            return(tz);
        }
Exemple #10
0
        /// <summary>
        /// Adds a system time zone to the iCalendar.  This time zone may
        /// then be used in date/time objects contained in the
        /// calendar.
        /// </summary>
        /// <param name="tzi">A System.TimeZoneInfo object to add to the calendar.</param>
        /// <returns>The time zone added to the calendar.</returns>
        public ITimeZone AddTimeZone(System.TimeZoneInfo tzi)
        {
            ITimeZone tz = iCalTimeZone.FromSystemTimeZone(tzi);

            this.AddChild(tz);
            return(tz);
        }
Exemple #11
0
 public ColdSpellLeftNotificationHandler(ISmsClient smsClient, IConfiguration configuration, IDateTimeProvider dateTimeProvider)
 {
     _smsClient        = smsClient;
     _configuration    = configuration;
     _dateTimeProvider = dateTimeProvider;
     _timeZone         = new GmtTimeZone();
 }
Exemple #12
0
        public void SystemTimeZone2()
        {
            System.TimeZoneInfo tzi = System.TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");
            Assert.IsNotNull(tzi);

            iCalendar iCal = new iCalendar();
            ITimeZone tz   = iCal.AddTimeZone(tzi, new DateTime(2000, 1, 1), false);

            Assert.IsNotNull(tz);

            iCalendarSerializer serializer = new iCalendarSerializer();

            serializer.Serialize(iCal, @"Calendars\Serialization\SystemTimeZone2.ics");

            // Ensure the time zone transition works as expected
            // (i.e. it takes 1 hour and 1 second to transition from
            // 2003-10-26 1:59:59 AM to
            // 2003-10-26 2:00:00 AM)
            iCalDateTime dt1    = new iCalDateTime(2003, 10, 26, 1, 59, 59, tz.TZID, iCal);
            iCalDateTime dt2    = new iCalDateTime(2003, 10, 26, 2, 0, 0, tz.TZID, iCal);
            TimeSpan     result = dt2 - dt1;

            Assert.AreEqual(TimeSpan.FromHours(1) + TimeSpan.FromSeconds(1), result);

            // Ensure another time zone transition works as expected
            // (i.e. it takes negative 59 minutes and 59 seconds to transition from
            // 2004-04-04 1:59:59 AM to
            // 2004-04-04 2:00:00 AM)
            dt1    = new iCalDateTime(2004, 4, 4, 1, 59, 59, tz.TZID, iCal);
            dt2    = new iCalDateTime(2004, 4, 4, 2, 0, 0, tz.TZID, iCal);
            result = dt2 - dt1;
            Assert.AreEqual(TimeSpan.FromHours(-1) + TimeSpan.FromSeconds(1), result);
        }
Exemple #13
0
        public IDateTime ToTimeZone(string tzid)
        {
            if (tzid != null)
            {
                if (Calendar != null)
                {
                    ITimeZone tz = Calendar.GetTimeZone(tzid);
                    if (tz != null)
                    {
                        return(ToTimeZone(tz));
                    }

                    // FIXME: sometimes a calendar is perfectly valid but the time zone
                    // could not be resolved.  What should we do here?
                    //throw new Exception("The '" + tzid + "' time zone could not be resolved.");
                    return(Copy <IDateTime>());
                }
                else
                {
                    throw new Exception("The iCalDateTime object must have an iCalendar associated with it in order to use TimeZones.");
                }
            }
            else
            {
                throw new ArgumentException("You must provide a valid TZID to the ToTimeZone() method", "tzid");
            }
        }
 public ColdSpellEnteredNotificationHandler(IColdSpellRepository coldSpellRepository, ISmsClient smsClient, IConfiguration configuration, IDateTimeProvider dateTimeProvider)
 {
     _coldSpellRepository = coldSpellRepository;
     _smsClient           = smsClient;
     _configuration       = configuration;
     _dateTimeProvider    = dateTimeProvider;
     _timeZone            = new GmtTimeZone();
 }
Exemple #15
0
 ///<summary>
 ///  GeoLocation constructor with parameters for all required fields.
 ///</summary>
 ///<param name = "name">
 ///  The location name for display use such as &quot;Lakewood,
 ///  NJ&quot; </param>
 ///<param name = "latitude">
 ///  the latitude in a double format such as 40.095965 for
 ///  Lakewood, NJ <br /> <b>Note: </b> For latitudes south of the
 ///  equator, a negative value should be used. </param>
 ///<param name = "longitude">
 ///  double the longitude in a double format such as -74.222130 for
 ///  Lakewood, NJ. <br /> <b>Note: </b> For longitudes east of the
 ///  <a href = "http://en.wikipedia.org/wiki/Prime_Meridian">Prime
 ///    Meridian </a> (Greenwich), a negative value should be used. </param>
 ///<param name = "elevation">
 ///  the elevation above sea level in Meters. Elevation is not used
 ///  in most algorithms used for calculating sunrise and set. </param>
 ///<param name = "timeZone">
 ///  the <c>TimeZone</c> for the location. </param>
 public GeoLocation(string name, double latitude, double longitude, double elevation, ITimeZone timeZone)
 {
     LocationName = name;
     Latitude     = latitude;
     Longitude    = longitude;
     Elevation    = elevation;
     TimeZone     = timeZone;
 }
Exemple #16
0
 /// <summary>
 ///     Sets the time zone.
 /// </summary>
 /// <param name="tz">The time zone.</param>
 /// <returns></returns>
 public IDateTime SetTimeZone(ITimeZone tz)
 {
     if (tz != null)
     {
         TzId = tz.TzId;
     }
     return(this);
 }
Exemple #17
0
 public IDateTime SetTimeZone(ITimeZone tz)
 {
     if (tz != null)
     {
         this.TZID = tz.TZID;
     }
     return(this);
 }
 public virtual bool TryGetTimeZone(string id, out ITimeZone result)
 {
     if (string.IsNullOrWhiteSpace(id))
     {
         throw new ArgumentNullException(nameof(id));
     }
     result = GetTimeZones().FirstOrDefault(x => x.Id == id);
     return(result != null);
 }
Exemple #19
0
        public TimeZoneInstance(ObjectInstance prototype, ITimeZone iTimeZone)
            : this(prototype)
        {
            if (iTimeZone == null)
            {
                throw new ArgumentNullException("iTimeZone");
            }

            m_iTimeZone = iTimeZone;
        }
Exemple #20
0
        public async Task <ITimeZone> GetLocalTimeZoneAsync()
        {
            // Caching the result per request
            if (_timeZone == null)
            {
                _timeZone = await LoadLocalTimeZoneAsync();
            }

            return(_timeZone);
        }
 private void AddTz(string tzId, ITimeZone timeZone, bool includeHistoricalData)
 {
     if (includeHistoricalData)
     {
         _tzHistoricalMap.Add(tzId, timeZone);
     }
     else
     {
         _tzOutlookMap.Add(tzId, timeZone);
     }
 }
 private void AddTz(string tzId, ITimeZone timeZone, bool includeHistoricalData)
 {
     if (includeHistoricalData)
     {
         _tzHistoricalMap.Add(tzId, timeZone);
     }
     else
     {
         _tzOutlookMap.Add(tzId, timeZone);
     }
 }
Exemple #23
0
 /// <summary>
 /// Set options for the region
 /// </summary>
 private void SetRegionOptions()
 {
     company = Factory.CreateBiggestCompany();
     capital = Factory.CreateCapital();
     currency = Factory.CreateCurrency();
     flagColors = Factory.CreateFlagColors();
     foundationYear = Factory.CreateFoundationYear();
     greetings = Factory.CreateGreetings();
     language = Factory.CreateLanguage();
     mostPopularReligion = Factory.CreateReligion();
     timeZone = Factory.CreateTimeZone();
     typeOfCountry = Factory.CreateTypeOfCountry();
 }
Exemple #24
0
        private static int getUTCOffset(ITimeZone fromZone, DateTime date)
        {
            var offset = fromZone.UtcOffsetSeconds;

            var isZoneInDST = fromZone.IsDaylightSavingsTime(date);

            if (isZoneInDST)
            {
                offset += 3600;
            }

            return(offset);
        }
 private TimeZoneObservance?GetTimeZoneObservance()
 {
     if (m_timeZoneObservance == null &&
         TZID != null &&
         Calendar != null)
     {
         ITimeZone tz = Calendar.GetTimeZone(TZID);
         if (tz != null)
         {
             m_timeZoneObservance = tz.GetTimeZoneObservance(this);
         }
     }
     return(m_timeZoneObservance);
 }
Exemple #26
0
 /// <summary>
 ///     Gets the time zone observance.
 /// </summary>
 /// <returns></returns>
 private TimeZoneObservance?GetTimeZoneObservance( )
 {
     if (_timeZoneObservance == null &&
         TzId != null &&
         Calendar != null)
     {
         ITimeZone tz = Calendar.GetTimeZone(TzId);
         if (tz != null)
         {
             _timeZoneObservance = tz.GetTimeZoneObservance(this);
         }
     }
     return(_timeZoneObservance);
 }
        public IDateTime ToTimeZone(ITimeZone tz)
        {
            if (tz == null)
            {
                throw new ArgumentException("You must provide a valid time zone to the ToTimeZone() method", "tz");
            }

            var tzi = tz.GetTimeZoneObservance(this);

            return(tzi.HasValue ? ToTimeZone(tzi.Value) : Copy <IDateTime>());

            // FIXME: if the time cannot be resolved, should we
            // just provide a copy?  Is this always appropriate?
        }
Exemple #28
0
 protected TimeZoneObservance?GetTimeZoneObservance()
 {
     if (_TimeZoneObservance == null &&
         TZID != null &&
         Calendar != null)
     {
         ITimeZone tz = Calendar.GetTimeZone(TZID);
         if (tz != null)
         {
             _TimeZoneObservance = tz.GetTimeZoneObservance(this);
         }
     }
     return(_TimeZoneObservance);
 }
Exemple #29
0
        /// <summary>
        ///     Merges this object with another.
        /// </summary>
        /// <param name="obj"></param>
        public virtual void MergeWith(IMergeable obj)
        {
            var c = obj as IICalendar;

            if (c != null)
            {
                if (Name == null)
                {
                    Name = c.Name;
                }

                foreach (ICalendarProperty p in c.Properties)
                {
                    if (!Properties.ContainsKey(p.Name))
                    {
                        Properties.Add(p.Copy <ICalendarProperty>( ));
                    }
                }
                foreach (ICalendarObject child in c.Children)
                {
                    var uniqueComponent = child as IUniqueComponent;

                    if (uniqueComponent != null)
                    {
                        IUniqueComponent component = UniqueComponents[uniqueComponent.Uid];
                        if (component == null)
                        {
                            this.AddChild(uniqueComponent.Copy <ICalendarObject>( ));
                        }
                    }
                    else
                    {
                        var timeZone = child as ITimeZone;

                        if (timeZone != null)
                        {
                            ITimeZone tz = GetTimeZone(timeZone.TzId);
                            if (tz == null)
                            {
                                this.AddChild(timeZone.Copy <ICalendarObject>( ));
                            }
                        }
                        else
                        {
                            this.AddChild(child.Copy <ICalendarObject>( ));
                        }
                    }
                }
            }
        }
Exemple #30
0
        virtual public void MergeWith(IMergeable obj)
        {
            IICalendar c = obj as IICalendar;

            if (c != null)
            {
                if (Name == null)
                {
                    Name = c.Name;
                }

                Method    = c.Method;
                Version   = c.Version;
                ProductID = c.ProductID;
                Scale     = c.Scale;

                foreach (ICalendarProperty p in c.Properties)
                {
                    if (!Properties.ContainsKey(p.Name))
                    {
                        Properties.Add(p.Copy <ICalendarProperty>());
                    }
                }
                foreach (ICalendarObject child in c.Children)
                {
                    if (child is IUniqueComponent)
                    {
                        if (!UniqueComponents.ContainsKey(((IUniqueComponent)child).UID))
                        {
                            AddChild(child.Copy <ICalendarObject>());
                        }
                    }
                    else if (child is ITimeZone)
                    {
                        ITimeZone tz = GetTimeZone(((ITimeZone)child).TZID);
                        if (tz == null)
                        {
                            AddChild(child.Copy <ICalendarObject>());
                        }
                    }
                    else
                    {
                        AddChild(child.Copy <ICalendarObject>());
                    }
                }
            }
        }
Exemple #31
0
        /// <summary>
        ///     To the time zone.
        /// </summary>
        /// <param name="tz">The time zone.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">@You must provide a valid time zone to the ToTimeZone() method;tz</exception>
        public IDateTime ToTimeZone(ITimeZone tz)
        {
            if (tz != null)
            {
                TimeZoneObservance?tzi = tz.GetTimeZoneObservance(this);
                if (tzi != null)
                {
                    return(ToTimeZone(tzi.Value));
                }

                // FIXME: if the time cannot be resolved, should we
                // just provide a copy?  Is this always appropriate?
                return(Copy <IDateTime>( ));
            }

            throw new ArgumentException(@"You must provide a valid time zone to the ToTimeZone() method", "tz");
        }
Exemple #32
0
        static void Main(string[] args)
        {
            // Create a new calendar
            IICalendar iCal = new iCalendar();

            // Add the local time zone to the calendar
            ITimeZone local = iCal.AddLocalTimeZone();

            // Build a list of additional time zones
            // from .NET Framework.
            List <ITimeZone> otherTimeZones = new List <ITimeZone>();

            foreach (TimeZoneInfo tzi in System.TimeZoneInfo.GetSystemTimeZones())
            {
                // We've already added the local time zone, so let's skip it!
                if (tzi != System.TimeZoneInfo.Local)
                {
                    // Add the time zone to our list (but don't include it directly in the calendar).
                    otherTimeZones.Add(iCalTimeZone.FromSystemTimeZone(tzi));
                }
            }

            // Create a new event in the calendar
            // that uses our local time zone
            IEvent evt = iCal.Create <Event>();

            evt.Summary  = "Test Event";
            evt.Start    = iCalDateTime.Today.AddHours(8).SetTimeZone(local);
            evt.Duration = TimeSpan.FromHours(1);

            // Get all occurrences of the event that happen today
            foreach (Occurrence occurrence in iCal.GetOccurrences <IEvent>(iCalDateTime.Today))
            {
                // Write the event with the time zone information attached
                Console.WriteLine(occurrence.Period.StartTime);

                // Note that the time printed is identical to the above, but without time zone information.
                Console.WriteLine(occurrence.Period.StartTime.Local);

                // Convert the start time to other time zones and display the relative time.
                foreach (ITimeZone otherTimeZone in otherTimeZones)
                {
                    Console.WriteLine(occurrence.Period.StartTime.ToTimeZone(otherTimeZone));
                }
            }
        }
Exemple #33
0
 ///<summary>
 ///  GeoLocation constructor with parameters for all required fields.
 ///</summary>
 ///<param name = "name">
 ///  The location name for display use such as &quot;Lakewood,
 ///  NJ&quot; </param>
 ///<param name = "latitude">
 ///  the latitude in a double format such as 40.095965 for
 ///  Lakewood, NJ <br /> <b>Note: </b> For latitudes south of the
 ///  equator, a negative value should be used. </param>
 ///<param name = "longitude">
 ///  double the longitude in a double format such as -74.222130 for
 ///  Lakewood, NJ. <br /> <b>Note: </b> For longitudes east of the
 ///  <a href = "http://en.wikipedia.org/wiki/Prime_Meridian">Prime
 ///    Meridian </a> (Greenwich), a negative value should be used. </param>
 ///<param name = "timeZone">
 ///  the <c>TimeZone</c> for the location. </param>
 public GeoLocation(string name, double latitude, double longitude, ITimeZone timeZone)
     : this(name, latitude, longitude, 0, timeZone)
 {
 }
Exemple #34
0
 ///<summary>
 ///  GeoLocation constructor with parameters for all required fields.
 ///</summary>
 ///<param name = "name">
 ///  The location name for display use such as &quot;Lakewood,
 ///  NJ&quot; </param>
 ///<param name = "latitude">
 ///  the latitude in a double format such as 40.095965 for
 ///  Lakewood, NJ <br /> <b>Note: </b> For latitudes south of the
 ///  equator, a negative value should be used. </param>
 ///<param name = "longitude">
 ///  double the longitude in a double format such as -74.222130 for
 ///  Lakewood, NJ. <br /> <b>Note: </b> For longitudes east of the
 ///  <a href = "http://en.wikipedia.org/wiki/Prime_Meridian">Prime
 ///    Meridian </a> (Greenwich), a negative value should be used. </param>
 ///<param name = "elevation">
 ///  the elevation above sea level in Meters. Elevation is not used
 ///  in most algorithms used for calculating sunrise and set. </param>
 ///<param name = "timeZone">
 ///  the <c>TimeZone</c> for the location. </param>
 public GeoLocation(string name, double latitude, double longitude, double elevation, ITimeZone timeZone)
 {
     LocationName = name;
     Latitude = latitude;
     Longitude = longitude;
     Elevation = elevation;
     TimeZone = timeZone;
 }
Exemple #35
0
 ///<summary>
 ///  GeoLocation constructor with parameters for all required fields.
 ///</summary>
 ///<param name = "latitude">
 ///  the latitude in a double format such as 40.095965 for
 ///  Lakewood, NJ <br /> <b>Note: </b> For latitudes south of the
 ///  equator, a negative value should be used. </param>
 ///<param name = "longitude">
 ///  double the longitude in a double format such as -74.222130 for
 ///  Lakewood, NJ. <br /> <b>Note: </b> For longitudes east of the
 ///  <a href = "http://en.wikipedia.org/wiki/Prime_Meridian">Prime
 ///    Meridian </a> (Greenwich), a negative value should be used. </param>
 ///<param name = "timeZone">
 ///  the <c>TimeZone</c> for the location. </param>
 public GeoLocation(double latitude, double longitude, ITimeZone timeZone)
     : this(string.Empty, latitude, longitude, 0, timeZone)
 {
 }
 public TimeZoneEvaluator(ITimeZone tz)
 {
     TimeZone = tz;
     m_Occurrences = new SortedList<Occurrence, Occurrence>();
 }
 public TimeZoneProtocol(ITimeZone timezone)
 {
     this.Name = timezone.Name;
     this.FullName = timezone.FullName;
     this.UtcOffsetSeconds = timezone.UtcOffsetSeconds;
 }
 public void SetTimezone(ITimeZone timezone)
 {
     _timezone = new Lazy<ITimeZone>(() => timezone);
 }
Exemple #39
0
        public IDateTime ToTimeZone(ITimeZone tz)
        {
            if (tz != null)
            {
                TimeZoneObservance? tzi = tz.GetTimeZoneObservance(this);
                if (tzi != null && tzi.HasValue)
                    return ToTimeZone(tzi.Value);

                // FIXME: if the time cannot be resolved, should we
                // just provide a copy?  Is this always appropriate?
                return Copy<IDateTime>();
            }
            else throw new ArgumentException("You must provide a valid time zone to the ToTimeZone() method", "tz");
        }
Exemple #40
0
 public IDateTime SetTimeZone(ITimeZone tz)
 {
     if (tz != null)
         this.TZID = tz.TZID;
     return this;
 }