System.TimeZoneInfo.GetAmbiguousTimeOffsets C# (CSharp) Method

GetAmbiguousTimeOffsets() public method

public GetAmbiguousTimeOffsets ( System.DateTime dateTime ) : System.TimeSpan[]
dateTime System.DateTime
return System.TimeSpan[]
		public TimeSpan [] GetAmbiguousTimeOffsets (DateTime dateTime)
		{
			if (!IsAmbiguousTime (dateTime))
				throw new ArgumentException ("dateTime is not an ambiguous time");

			AdjustmentRule rule = GetApplicableRule (dateTime);
			if (rule != null)
				return new TimeSpan[] {baseUtcOffset, baseUtcOffset + rule.DaylightDelta};
			else
				return new TimeSpan[] {baseUtcOffset, baseUtcOffset};
		}

Same methods

TimeZoneInfo::GetAmbiguousTimeOffsets ( DateTimeOffset dateTimeOffset ) : System.TimeSpan[]

Usage Example

Esempio n. 1
0
        public static TimeSpan GetUtcOffset(DateTime dateTime, TimeZoneInfo timeZoneInfo)
        {
            // Unlike the default behavior of TimeZoneInfo.GetUtcOffset, it is prefered to choose
            // the DAYLIGHT time when the input is ambiguous, because the daylight instance is the
            // FIRST instance, and time moves in a forward direction.

            TimeSpan offset = timeZoneInfo.IsAmbiguousTime(dateTime)
                ? timeZoneInfo.GetAmbiguousTimeOffsets(dateTime).Max()
                : timeZoneInfo.GetUtcOffset(dateTime);

            return offset;
        }
All Usage Examples Of System.TimeZoneInfo::GetAmbiguousTimeOffsets