CalculateUtcOffset() static private method

static private CalculateUtcOffset ( System.DateTime time, DaylightTime daylightTimes ) : System.TimeSpan
time System.DateTime
daylightTimes System.Globalization.DaylightTime
return System.TimeSpan
コード例 #1
0
 // Token: 0x06000CF3 RID: 3315 RVA: 0x0002795C File Offset: 0x00025B5C
 public override TimeSpan GetUtcOffset(DateTime time)
 {
     if (time.Kind == DateTimeKind.Utc)
     {
         return(TimeSpan.Zero);
     }
     return(new TimeSpan(TimeZone.CalculateUtcOffset(time, this.GetDaylightChanges(time.Year)).Ticks + this.m_ticksOffset));
 }
コード例 #2
0
        internal long GetUtcOffsetFromUniversalTime(DateTime time)
        {
            // Get the daylight changes for the year of the specified time.
            DaylightTime daylightTime = GetDaylightChanges(time.Year);
            // This is the UTC offset for the time (which is based on Universal time), but it is calculated according to local timezone rule.
            long utcOffset = TimeZone.CalculateUtcOffset(time, daylightTime).Ticks + m_ticksOffset;
            long ticks     = time.Ticks;

            if (daylightTime.Delta.Ticks != 0)
            {
                // This timezone uses daylight saving rules.
                if (m_ticksOffset < 0)
                {
                    // This deals with GMT-XX timezones (e.g. Pacific Standard time).
                    if ((ticks >= daylightTime.Start.Ticks + daylightTime.Delta.Ticks) && (ticks < daylightTime.Start.Ticks - m_ticksOffset))
                    {
                        return(utcOffset - daylightTime.Delta.Ticks);
                    }
                    if ((ticks >= daylightTime.End.Ticks) && (ticks < daylightTime.End.Ticks - m_ticksOffset - daylightTime.Delta.Ticks))
                    {
                        return(utcOffset + daylightTime.Delta.Ticks);
                    }
                }
                else
                {
                    // This deals with GMT+XX timezones.
                    if ((ticks >= daylightTime.Start.Ticks - m_ticksOffset) && (ticks < daylightTime.Start.Ticks + daylightTime.Delta.Ticks))
                    {
                        return(utcOffset + daylightTime.Delta.Ticks);
                    }
                    if ((ticks >= daylightTime.End.Ticks - m_ticksOffset - daylightTime.Delta.Ticks) && (ticks < daylightTime.End.Ticks))
                    {
                        return(utcOffset - daylightTime.Delta.Ticks);
                    }
                }
            }
            return(utcOffset);
        }
コード例 #3
0
 /// <summary>Returns a value indicating whether the specified date and time is within the specified daylight saving time period.</summary>
 /// <param name="time">A date and time. </param>
 /// <param name="daylightTimes">A daylight saving time period. </param>
 /// <returns>
 ///     <see langword="true" /> if <paramref name="time" /> is in <paramref name="daylightTimes" />; otherwise, <see langword="false" />.</returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="daylightTimes" /> is <see langword="null" />. </exception>
 // Token: 0x0600138F RID: 5007 RVA: 0x0003902B File Offset: 0x0003722B
 public static bool IsDaylightSavingTime(DateTime time, DaylightTime daylightTimes)
 {
     return(TimeZone.CalculateUtcOffset(time, daylightTimes) != TimeSpan.Zero);
 }
コード例 #4
0
 public override TimeSpan GetUtcOffset(DateTime time)
 {
     return(new TimeSpan(TimeZone.CalculateUtcOffset(time, GetDaylightChanges(time.Year)).Ticks + m_ticksOffset));
 }