Bewerken

Share via


TimeZoneInfo.CreateCustomTimeZone Method

Definition

Defines a time zone that is not found on the local computer.

Overloads

CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[], Boolean)

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, daylight saving time rules, and a value that indicates whether the returned object reflects daylight saving time information.

CreateCustomTimeZone(String, TimeSpan, String, String)

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, and a standard time display name.

CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[])

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, and daylight saving time rules.

CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[], Boolean)

Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, daylight saving time rules, and a value that indicates whether the returned object reflects daylight saving time information.

public:
 static TimeZoneInfo ^ CreateCustomTimeZone(System::String ^ id, TimeSpan baseUtcOffset, System::String ^ displayName, System::String ^ standardDisplayName, System::String ^ daylightDisplayName, cli::array <TimeZoneInfo::AdjustmentRule ^> ^ adjustmentRules, bool disableDaylightSavingTime);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string? displayName, string? standardDisplayName, string? daylightDisplayName, TimeZoneInfo.AdjustmentRule[]? adjustmentRules, bool disableDaylightSavingTime);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName, string daylightDisplayName, TimeZoneInfo.AdjustmentRule[] adjustmentRules, bool disableDaylightSavingTime);
static member CreateCustomTimeZone : string * TimeSpan * string * string * string * TimeZoneInfo.AdjustmentRule[] * bool -> TimeZoneInfo
Public Shared Function CreateCustomTimeZone (id As String, baseUtcOffset As TimeSpan, displayName As String, standardDisplayName As String, daylightDisplayName As String, adjustmentRules As TimeZoneInfo.AdjustmentRule(), disableDaylightSavingTime As Boolean) As TimeZoneInfo

Parameters

id
String

The time zone's identifier.

baseUtcOffset
TimeSpan

A TimeSpan object that represents the time difference between this time zone and Coordinated Universal Time (UTC).

displayName
String

The display name of the new time zone.

standardDisplayName
String

The standard time name of the new time zone.

daylightDisplayName
String

The daylight saving time name of the new time zone.

adjustmentRules
TimeZoneInfo.AdjustmentRule[]

An array of TimeZoneInfo.AdjustmentRule objects that augment the base UTC offset for a particular period.

disableDaylightSavingTime
Boolean

true to discard any daylight saving time-related information present in adjustmentRules with the new object; otherwise, false.

Returns

The new time zone. If the disableDaylightSavingTime parameter is true, the returned object has no daylight saving time data.

Exceptions

The id parameter is null.

The id parameter is an empty string ("").

-or-

The baseUtcOffset parameter does not represent a whole number of minutes.

The baseUtcOffset parameter is greater than 14 hours or less than -14 hours.

The adjustment rules specified in the adjustmentRules parameter overlap.

-or-

The adjustment rules specified in the adjustmentRules parameter are not in chronological order.

-or-

One or more elements in adjustmentRules are null.

-or-

A date can have multiple adjustment rules applied to it.

-or-

The sum of the baseUtcOffset parameter and the DaylightDelta value of one or more objects in the adjustmentRules array is greater than 14 hours or less than -14 hours.

Examples

The following example creates a custom time zone for the Palmer station and Anvers Island in Antarctica. It sets the disableDaylightSavingTime parameter in the call to the TimeZoneInfo.CreateCustomTimeZone method to true. It then displays the new time zone's daylight saving time name, if one is present, and the number of adjustment rules to confirm that the new time zone has no daylight saving time information.

// Define transition times to/from DST
TimeZoneInfo.TransitionTime startTransition, endTransition;
startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 4, 0, 0),
                                                                  10, 2, DayOfWeek.Sunday); 
endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1,3, 0, 0), 
                                                                3, 2, DayOfWeek.Sunday);
// Define adjustment rule
TimeSpan delta = new TimeSpan(1, 0, 0);
TimeZoneInfo.AdjustmentRule adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1999, 10, 1), 
                                      DateTime.MaxValue.Date, delta, startTransition, endTransition);
// Create array for adjustment rules
TimeZoneInfo.AdjustmentRule[] adjustments = {adjustment};
// Define other custom time zone arguments
string displayName = "(GMT-04:00) Antarctica/Palmer Time";
string standardName = "Palmer Standard Time";
string daylightName = "Palmer Daylight Time";
TimeSpan offset = new TimeSpan(-4, 0, 0);
// Create custom time zone without copying DST information
TimeZoneInfo palmer = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, 
                                                  daylightName, adjustments, true);
// Indicate whether new time zone//s adjustment rules are present
Console.WriteLine("{0} {1}has {2} adjustment rules.", 
                  palmer.StandardName, 
                  ! (string.IsNullOrEmpty(palmer.DaylightName)) ?  "(" + palmer.DaylightName + ") ": "" , 
                  palmer.GetAdjustmentRules().Length);
// Indicate whether new time zone supports DST
Console.WriteLine("{0} supports DST: {1}", palmer.StandardName, palmer.SupportsDaylightSavingTime);
// Define transition times to/from DST
let startTransition = 
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 4, 0, 0), 10, 2, DayOfWeek.Sunday) 
let endTransition = 
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1,3, 0, 0), 3, 2, DayOfWeek.Sunday)
// Define adjustment rule
let delta = TimeSpan(1, 0, 0)
let adjustment = 
    TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition)
// Create array for adjustment rules
let adjustments = [| adjustment |]
// Define other custom time zone arguments
let displayName = "(GMT-04:00) Antarctica/Palmer Time"
let standardName = "Palmer Standard Time"
let daylightName = "Palmer Daylight Time"
let offset = TimeSpan(-4, 0, 0)
// Create custom time zone without copying DST information
let palmer = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, daylightName, adjustments, true)
// Indicate whether time zone//s adjustment rules are present
printfn $"""{palmer.StandardName} {if String.IsNullOrEmpty palmer.DaylightName then "" else "(" + palmer.DaylightName + ")"}has {palmer.GetAdjustmentRules().Length} adjustment rules."""
// Indicate whether time zone supports DST
printfn $"{palmer.StandardName} supports DST: {palmer.SupportsDaylightSavingTime}"
' Define transition times to/from DST
Dim startTransition As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#04:00:00#, 10, 2, DayOfWeek.Sunday) 
Dim endTransition As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#3:00:00#, 3, 2, DayOfWeek.Sunday)
' Define adjustment rule
Dim delta As TimeSpan = New TimeSpan(1, 0, 0)
Dim adjustment As TimeZoneInfo.AdjustmentRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#10/01/1999#, Date.MaxValue.Date, delta, startTransition, endTransition)
' Create array for adjustment rules
Dim adjustments() As TimeZoneInfo.AdjustmentRule = {adjustment}
' Define other custom time zone arguments
Dim displayName As String = "(GMT-04:00) Antarctica/Palmer Time"
Dim standardName As String = "Palmer Standard Time"
Dim daylightName As String = "Palmer Daylight Time"
Dim offset As TimeSpan = New TimeSpan(-4, 0, 0)
Dim palmer As TimeZoneInfo = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, daylightName, adjustments, True)
' Indicate whether new time zone's adjustment rules are present
Console.WriteLine("{0} {1}has {2} adjustment rules.", _
                  palmer.StandardName, _
                  IIf(Not String.IsNullOrEmpty(palmer.DaylightName), "(" & palmer.DaylightName & ") ", ""), _
                  palmer.GetAdjustmentRules().Length)
' Indicate whether new time zone supports DST
Console.WriteLine("{0} supports DST: {1}", palmer.StandardName, palmer.SupportsDaylightSavingTime)

Remarks

You can use this overload of the TimeZoneInfo.CreateCustomTimeZone method to create a custom time zone whose support for daylight saving time can be determined by conditions at run time.

The following table shows the relationship between the parameters that are provided to the TimeZoneInfo.CreateCustomTimeZone method and the members of the TimeZoneInfo object that are returned by the method call.

CreateCustomTimeZone parameter TimeZoneInfo property
id Id
baseUtcOffset BaseUtcOffset
displayName DisplayName
standardDisplayName StandardName
daylightDisplayName DaylightName if disableDaylightSavingTime is false; String.Empty if disableDaylightSavingTime is true.
adjustmentRules An array of TimeZoneInfo.AdjustmentRule objects returned by the GetAdjustmentRules method if disableDaylightSavingTime is false; an empty array returned by the GetAdjustmentRules method if disableDaylightSavingTime is true.
disableDaylightSavingTime Not SupportsDaylightSavingTime.

Typically, the time zone's standard time name and its identifier are the same. However, the length of the time zone's identifier should not exceed 32 characters. The string passed to the displayName parameter follows a fairly standard format. The first portion of the display name is the time zone's base offset from Coordinated Universal Time, which is indicated by the acronym GMT (for Greenwich Mean Time), enclosed in parentheses. This is followed by a string that identifies the time zone itself, or one or more of the cities, regions, or countries in the time zone, or both. For example:

(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT-02:00) Mid-Atlantic
(GMT-07:00) Mountain Time (US & Canada)

A time zone's adjustment rules are defined by doing the following:

  1. Calling either the CreateFloatingDateRule or the CreateFixedDateRule method to define the starting and ending transition rules for each adjustment rule.

  2. Calling the CreateAdjustmentRule method for each adjustment rule.

  3. Assigning the adjustment rules to an array that can be passed as the adjustmentRules parameter.

If disableDaylightSavingTime parameter is false, the operation of this method is identical to the TimeZoneInfo.CreateCustomTimeZone overload. If disableDaylightSavingTime is true, the returned object includes no adjustment rules and a DaylightName property whose value is an empty string.

See also

Applies to

CreateCustomTimeZone(String, TimeSpan, String, String)

Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, and a standard time display name.

public:
 static TimeZoneInfo ^ CreateCustomTimeZone(System::String ^ id, TimeSpan baseUtcOffset, System::String ^ displayName, System::String ^ standardDisplayName);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string? displayName, string? standardDisplayName);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName);
static member CreateCustomTimeZone : string * TimeSpan * string * string -> TimeZoneInfo
Public Shared Function CreateCustomTimeZone (id As String, baseUtcOffset As TimeSpan, displayName As String, standardDisplayName As String) As TimeZoneInfo

Parameters

id
String

The time zone's identifier.

baseUtcOffset
TimeSpan

An object that represents the time difference between this time zone and Coordinated Universal Time (UTC).

displayName
String

The display name of the new time zone.

standardDisplayName
String

The name of the new time zone's standard time.

Returns

The new time zone.

Exceptions

The id parameter is null.

The id parameter is an empty string ("").

-or-

The baseUtcOffset parameter does not represent a whole number of minutes.

The baseUtcOffset parameter is greater than 14 hours or less than -14 hours.

Examples

The following example creates a custom time zone for the Mawson and Holme Bay regions of Antarctica. It then displays the result of converting the local time to the time in the new time zone.

string displayName = "(GMT+06:00) Antarctica/Mawson Time";
string standardName = "Mawson Time"; 
TimeSpan offset = new TimeSpan(06, 00, 00);
TimeZoneInfo mawson = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName);
Console.WriteLine("The current time is {0} {1}", 
                  TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, mawson),
                  mawson.StandardName);
let displayName = "(GMT+06:00) Antarctica/Mawson Time"
let standardName = "Mawson Time" 
let offset = TimeSpan(06, 00, 00)
let mawson = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName)
printfn $"The current time is {TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, mawson)} {mawson.StandardName}"
Dim displayName As String = "(GMT+06:00) Antarctica/Mawson Time"
Dim standardName As String = "Mawson Time" 
Dim offset As TimeSpan = New TimeSpan(06, 00, 00)
Dim mawson As TimeZoneInfo = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName)
Console.WriteLine("The current time is {0} {1}", _ 
                  TimeZoneInfo.ConvertTime(Date.Now, TimeZoneInfo.Local, mawson), _
                  mawson.StandardName)

Remarks

This overload of the CreateCustomTimeZone(String, TimeSpan, String, String) method is suitable for creating a time zone that has no adjustments (that is, a time zone that does not support daylight saving time). To define a time zone that includes adjustments for daylight saving time, use either the TimeZoneInfo.CreateCustomTimeZone or the TimeZoneInfo.CreateCustomTimeZone method.

The following table shows the relationship between the parameters that are provided to the TimeZoneInfo.CreateCustomTimeZone method and the properties of the TimeZoneInfo object that are returned by the method call.

CreateCustomTimeZone parameter TimeZoneInfo property
id Id
baseUtcOffset BaseUtcOffset
displayName DisplayName
standardDisplayName StandardName

Typically, the time zone's standard time name and its identifier are the same. However, the length of the time zone's identifier should not exceed 32 characters. The string passed to the displayName parameter follows a fairly standard format. The first portion of the display name is the time zone's base offset from Coordinated Universal Time, which is indicated by the acronym GMT (for Greenwich Mean Time), enclosed in parentheses. This is followed by a string that identifies the time zone itself, or one or more of the cities, regions, or countries in the time zone, or both. For example:

(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT-02:00) Mid-Atlantic
(GMT-07:00) Mountain Time (US & Canada)

See also

Applies to

CreateCustomTimeZone(String, TimeSpan, String, String, String, TimeZoneInfo+AdjustmentRule[])

Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs
Source:
TimeZoneInfo.cs

Creates a custom time zone with a specified identifier, an offset from Coordinated Universal Time (UTC), a display name, a standard time name, a daylight saving time name, and daylight saving time rules.

public:
 static TimeZoneInfo ^ CreateCustomTimeZone(System::String ^ id, TimeSpan baseUtcOffset, System::String ^ displayName, System::String ^ standardDisplayName, System::String ^ daylightDisplayName, cli::array <TimeZoneInfo::AdjustmentRule ^> ^ adjustmentRules);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string? displayName, string? standardDisplayName, string? daylightDisplayName, TimeZoneInfo.AdjustmentRule[]? adjustmentRules);
public static TimeZoneInfo CreateCustomTimeZone (string id, TimeSpan baseUtcOffset, string displayName, string standardDisplayName, string daylightDisplayName, TimeZoneInfo.AdjustmentRule[] adjustmentRules);
static member CreateCustomTimeZone : string * TimeSpan * string * string * string * TimeZoneInfo.AdjustmentRule[] -> TimeZoneInfo
Public Shared Function CreateCustomTimeZone (id As String, baseUtcOffset As TimeSpan, displayName As String, standardDisplayName As String, daylightDisplayName As String, adjustmentRules As TimeZoneInfo.AdjustmentRule()) As TimeZoneInfo

Parameters

id
String

The time zone's identifier.

baseUtcOffset
TimeSpan

An object that represents the time difference between this time zone and Coordinated Universal Time (UTC).

displayName
String

The display name of the new time zone.

standardDisplayName
String

The new time zone's standard time name.

daylightDisplayName
String

The daylight saving time name of the new time zone.

adjustmentRules
TimeZoneInfo.AdjustmentRule[]

An array that augments the base UTC offset for a particular period.

Returns

A TimeZoneInfo object that represents the new time zone.

Exceptions

The id parameter is null.

The id parameter is an empty string ("").

-or-

The baseUtcOffset parameter does not represent a whole number of minutes.

The baseUtcOffset parameter is greater than 14 hours or less than -14 hours.

The adjustment rules specified in the adjustmentRules parameter overlap.

-or-

The adjustment rules specified in the adjustmentRules parameter are not in chronological order.

-or-

One or more elements in adjustmentRules are null.

-or-

A date can have multiple adjustment rules applied to it.

-or-

The sum of the baseUtcOffset parameter and the DaylightDelta value of one or more objects in the adjustmentRules array is greater than 14 hours or less than -14 hours.

Examples

The following example creates a custom time zone for the Palmer station and Anvers Island in Antarctica. It then converts the local time to the time in the new time zone and displays the result.

// Define transition times to/from DST
TimeZoneInfo.TransitionTime startTransition, endTransition;
startTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 4, 0, 0), 
                                                                  10, 2, DayOfWeek.Sunday); 
endTransition = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 
                                                                3, 2, DayOfWeek.Sunday);
// Define adjustment rule
TimeSpan delta = new TimeSpan(1, 0, 0);
TimeZoneInfo.AdjustmentRule adjustment;
adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition);
// Create array for adjustment rules
TimeZoneInfo.AdjustmentRule[] adjustments = {adjustment};
// Define other custom time zone arguments
string displayName = "(GMT-04:00) Antarctica/Palmer Time";
string standardName = "Palmer Time";
string daylightName = "Palmer Daylight Time";
TimeSpan offset = new TimeSpan(-4, 0, 0);
TimeZoneInfo palmer = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, daylightName, adjustments);
Console.WriteLine("The current time is {0} {1}",  
                  TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, palmer), 
                  palmer.StandardName);
// Define transition times to/from DST
let startTransition = 
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 4, 0, 0), 10, 2, DayOfWeek.Sunday) 
let endTransition = 
    TimeZoneInfo.TransitionTime.CreateFloatingDateRule(DateTime(1, 1, 1, 3, 0, 0), 3, 2, DayOfWeek.Sunday)
// Define adjustment rule
let delta = TimeSpan(1, 0, 0)
let adjustment = 
    TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(DateTime(1999, 10, 1), DateTime.MaxValue.Date, delta, startTransition, endTransition)
// Create array for adjustment rules
let adjustments = [| adjustment |]
// Define other custom time zone arguments
let displayName = "(GMT-04:00) Antarctica/Palmer Time"
let standardName = "Palmer Time"
let daylightName = "Palmer Daylight Time"
let offset = TimeSpan(-4, 0, 0)
let palmer = 
    TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, daylightName, adjustments)
printfn $"The current time is {TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, palmer)} {palmer.StandardName}"
' Define transition times to/from DST
Dim startTransition As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#04:00:00#, 10, 2, DayOfWeek.Sunday) 
Dim endTransition As TimeZoneInfo.TransitionTime = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#3:00:00#, 3, 2, DayOfWeek.Sunday)
' Define adjustment rule
Dim delta As TimeSpan = New TimeSpan(1, 0, 0)
Dim adjustment As TimeZoneInfo.AdjustmentRule = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#10/01/1999#, Date.MaxValue.Date, delta, startTransition, endTransition)
' Create array for adjustment rules
Dim adjustments() As TimeZoneInfo.AdjustmentRule = {adjustment}
' Define other custom time zone arguments
Dim DisplayName As String = "(GMT-04:00) Antarctica/Palmer Time"
Dim standardName As String = "Palmer Standard Time"
Dim daylightName As String = "Palmer Daylight Time"
Dim offset As TimeSpan = New TimeSpan(-4, 0, 0)
Dim palmer As TimeZoneInfo = TimeZoneInfo.CreateCustomTimeZone(standardName, offset, displayName, standardName, daylightName, adjustments)
Console.WriteLine("The current time is {0} {1}", _ 
                  TimeZoneInfo.ConvertTime(Date.Now, TimeZoneInfo.Local, palmer), _
                  palmer.StandardName)

Remarks

This overload of the TimeZoneInfo.CreateCustomTimeZone method is suitable for creating a time zone that supports daylight saving time. To define a time zone that does not support daylight saving time, use either the TimeZoneInfo.CreateCustomTimeZone or the TimeZoneInfo.CreateCustomTimeZone method.

The following table shows the relationship between the parameters that are provided to the TimeZoneInfo.CreateCustomTimeZone method and the members of the TimeZoneInfo object that are returned by the method call.

CreateCustomTimeZone parameter TimeZoneInfo member
id Id
baseUtcOffset BaseUtcOffset
displayName DisplayName
standardDisplayName StandardName
daylightDisplayName DaylightName
adjustmentRules An array of System.TimeZoneInfo.AdjustmentRule objects returned by the GetAdjustmentRules method.

Typically, the time zone's standard time name and its identifier are the same. However, the length of the time zone's identifier should not exceed 32 characters. The string passed to the displayName parameter follows a fairly standard format. The first portion of the display name is the time zone's base offset from Coordinated Universal Time, which is indicated by the acronym GMT (for Greenwich Mean Time), enclosed in parentheses. This is followed by a string that identifies the time zone itself, or one or more of the cities, regions, or countries in the time zone, or both. For example:

(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT-02:00) Mid-Atlantic
(GMT-07:00) Mountain Time (US & Canada)

The baseUtcOffset parameter defines the custom time zone's offset from Coordinated Universal Time (UTC) for all of the time zone's adjustment rules. In other words, the TimeZoneInfo object model assumes that the time zone's offset from UTC is constant throughout the life of the time zone, and exists independent of particular adjustment rules. To reflect a time zone that has changed its offset from UTC, you must create a new time zone object.

A time zone's adjustment rules are defined by doing the following:

  1. Calling either the CreateFloatingDateRule or the CreateFixedDateRule method to define the starting and ending transition time for each adjustment rule.

  2. Calling the CreateAdjustmentRule method for each adjustment rule.

  3. Assigning the adjustment rules to an array that can be passed as the adjustmentRules parameter.

See also

Applies to