ConvertFromUtc Method
Definition
- Namespace
- Tyne
- Assembly
- Tyne.Core.dll
Methods
| Edit this page View SourceConvertFromUtc(DateTime, TimeZoneInfo)
Converts a sourceDateTime into a DateTime in the targetTimeZone.
Declaration
public static DateTime ConvertFromUtc(this DateTime sourceDateTime, TimeZoneInfo targetTimeZone)
Parameters
sourceDateTime- DateTime
A DateTime in UTC. This may be Utc or Unspecified. An ArgumentException will be thrown if it is Local.
targetTimeZone- TimeZoneInfo
The TimeZoneInfo for the DateTimeOffset to be in.
Returns
DateTimeA DateTime representing sourceDateTime in targetTimeZone.
Remarks
This returns a DateTime, which loses any offset context. Consider using ConvertFromUtcAsOffset(DateTime, TimeZoneInfo) to return a DateTimeOffset which retains the offset.
Exceptions
- ArgumentException
When
sourceDateTimeis Local.
- ArgumentException
When
targetTimeZoneis null.