Table of Contents

ConvertFromUtc Method

Definition

Namespace
Tyne
Assembly
Tyne.Core.dll

Methods

| Edit this page View Source

ConvertFromUtc(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
DateTime

A 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 sourceDateTime is Local.

ArgumentException

When targetTimeZone is null.