IdtTimeZoneToUniversalTime Method

Returns the Universal Coordinated Time (UTC) that corresponds to a specified local time.

Definition

Namespace: InnerDrive.TimeZones
Assembly: InnerDrive.TimeZones (in InnerDrive.TimeZones.dll) Version: 5.2.9017.0
C#
public DateTimeOffset ToUniversalTime(
	DateTime time
)

Parameters

time  DateTime
A local time.

Return Value

DateTimeOffset
A DateTime instance whose value is the UTC that corresponds to time.

Remarks

Some local times do not actually exist, and therefore cannot be translated to UTC. For example, using U.S. rules, daylight saving time returns on the second Sunday of March at 2:00 am local time. Wall clock time advances from 1:59:59 to 3:00:00. Therefore, 2:30 am on that day never actually happens.

Conversely, some local times happen more than once, as when standard time returns to the U.S. on the second Sunday of November. On that day, 1:59:59 am daylight saving time goes to 1:00:00 am standard time, so all the local times between 1:00:00 and 2:00:00 repeat. In this case, the method will choose either the earlier TimeZoneRule or the later TimeChangeRule, which may yield unexpected results.

Exceptions

ArgumentExceptiontime cannot be represented as a UTC value

See Also