ConvertFromUtcAsOffset Method
Definition
- Namespace
- Tyne
- Assembly
- Tyne.Core.dll
Methods
| Edit this page View SourceConvertFromUtcAsOffset(DateTime, TimeZoneInfo)
Converts a sourceDateTime
into a DateTimeOffset in the targetTimeZone
.
Declaration
public static DateTimeOffset ConvertFromUtcAsOffset(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 as we don't know enough about the DateTime to convert it to UTC first.
targetTimeZone
- TimeZoneInfo
The TimeZoneInfo for the DateTime to be in.
Returns
DateTimeOffsetA DateTimeOffset representing sourceDateTime
in targetTimeZone
.
Remarks
This returns a DateTimeOffset which encodes the targetTimeZone
's offset.
If this offset isn't useful, consider using ConvertFromUtc(DateTime, TimeZoneInfo).
Exceptions
- ArgumentException
When
sourceDateTime
is Local.
- ArgumentException
When
targetTimeZone
is null.