Exemple #1
0
            // Get the daylight saving time rules for this timezone in a given year.
            public override DaylightTime GetDaylightChanges(int year)
            {
                long start, end, delta;

                if (year < 1 || year > 9999)
                {
                    throw new ArgumentOutOfRangeException
                              (_("ArgRange_Year"));
                }
                lock (this)
                {
                    if (cachedYear == year)
                    {
                        return(cachedChanges);
                    }
                    if (TimeMethods.GetDaylightRules
                            (year, out start, out end, out delta))
                    {
                        cachedChanges = new DaylightTime
                                            (new DateTime(start),
                                            new DateTime(end),
                                            new TimeSpan(delta));
                    }
                    else
                    {
                        cachedChanges = new DaylightTime
                                            (DateTime.MinValue, DateTime.MaxValue,
                                            TimeSpan.Zero);
                    }
                    cachedYear = year;
                    return(cachedChanges);
                }
            }
Exemple #2
0
 // Convert this DateTime value into UTC time.
 public DateTime ToUniversalTime()
 {
     return(new DateTime
                (value_ + ((long)(TimeMethods.GetTimeZoneAdjust(value_))) *
                TimeSpan.TicksPerSecond));
 }
Exemple #3
0
            // Get the offset from UTC of this timezone at a given time.
            public override TimeSpan GetUtcOffset(DateTime time)
            {
                int secs = TimeMethods.GetTimeZoneAdjust(time.Ticks);

                return(new TimeSpan(-secs * TimeSpan.TicksPerSecond));
            }