Table of Contents

ConvertToUtcAsOffset Method

Definition

Namespace
Tyne
Assembly
Tyne.Core.dll

Methods

| Edit this page View Source

ConvertToUtcAsOffset(DateTime, TimeZoneInfo)

Converts a sourceDateTime in the sourceTimeZone into a DateTimeOffset.

Declaration
public static DateTimeOffset ConvertToUtcAsOffset(this DateTime sourceDateTime, TimeZoneInfo sourceTimeZone)
Parameters
sourceDateTime
DateTime

A local DateTime. This may be Local or Unspecified. An ArgumentException will be thrown if it is Utc.

sourceTimeZone
TimeZoneInfo

The TimeZoneInfo which the sourceDateTime is in.

Returns
DateTimeOffset

A DateTimeOffset representing sourceDateTime in sourceTimeZone.

Remarks

This returns a DateTimeOffset which encodes the sourceTimeZone's offset. If this offset isn't useful, consider using ConvertToUtc(DateTime, TimeZoneInfo).

Exceptions
ArgumentException

When sourceDateTime is Utc.

ArgumentException

When sourceTimeZone is null.