System.TimeZone Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Represents a time zone.
C# Syntax:
[Serializable]
public abstract class TimeZone
Remarks
A time zone is a geographical region in which the same standard time is used.
See also:
System Namespace

System.TimeZone Member List:

Public Properties
CurrentTimeZone Read-only

Gets the time zone of the current computer system.
DaylightName Read-only

Gets the daylight saving time zone name.
StandardName Read-only

Gets the standard time zone name.
Public Methods
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetDaylightChanges Returns the daylight saving time period for a particular year.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
GetUtcOffset Returns the coordinated universal time (UTC) offset for the specified local time.
IsDaylightSavingTime Overloaded:
IsDaylightSavingTime(DateTime time)

Returns a value indicating whether the specified date and time is within a daylight saving time period.
IsDaylightSavingTime Overloaded:
IsDaylightSavingTime(DateTime time, DaylightTime daylightTimes)

Returns a value indicating whether the specified date and time is within the specified daylight saving time period.
ToLocalTime Returns the local time that corresponds to a specified coordinated universal time (UTC).
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
ToUniversalTime Returns the coordinated universal time (UTC) that corresponds to a specified local time.
Protected Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the TimeZone class.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.TimeZone Member Details

ctor #1
Summary
Initializes a new instance of the TimeZone class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected TimeZone();

Return to top


Property: CurrentTimeZone (read-only)
Summary
Gets the time zone of the current computer system.
C# Syntax:
public static TimeZone CurrentTimeZone {get;}

Return to top


Property: DaylightName (read-only)
Summary
Gets the daylight saving time zone name.
C# Syntax:
public abstract string DaylightName {get;}
Remarks
If daylight saving time is not used in the time zone, an empty string ("") is returned.

Return to top


Property: StandardName (read-only)
Summary
Gets the standard time zone name.
C# Syntax:
public abstract string StandardName {get;}
Exceptions
Exception Type Condition
ArgumentNullException Attempted to set this property to null.
See also:
String

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~TimeZone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetDaylightChanges(
   int year
)
Summary
Returns the daylight saving time period for a particular year.
C# Syntax:
public abstract DaylightTime GetDaylightChanges(
   int year
);
Parameters:

year

The year to which the daylight saving time period applies.

Return Value:
A DaylightTime instance containing the start and end date for daylight saving time in year.
Exceptions
Exception Type Condition
ArgumentOutOfRangeException year is less than 1 or greater than 9999.
Remarks
Only one daylight saving time period per year is supported. If daylight saving time is not used in the current time zone, null is returned.
See also:
Int32

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetUtcOffset(
   DateTime time
)
Summary
Returns the coordinated universal time (UTC) offset for the specified local time.
C# Syntax:
public abstract TimeSpan GetUtcOffset(
   DateTime time
);
Parameters:

time

The local date and time.

Return Value:
The UTC offset from time, measured in ticks.
Remarks
Coordinated universal time (UTC) was previously known as Greenwich Mean Time (GMT). Local time is the date and time on the computer you are using. Offset is the difference between local time and UTC. That is:

local time = UTC + offset

time must be in the Gregorian calendar and the time zone represented by this instance. If time is in daylight saving time, this method returns the UTC offset to the daylight saving time zone. This method obtains the daylight saving time rule from the system.

For example, in the United States Pacific Standard time zone, which has -8 hours of offset, GetUtcOffset(new DateTime(1999, 1, 1)) returns -288000000000.

Return to top


Overloaded Method: IsDaylightSavingTime(
   DateTime time
)
Summary
Returns a value indicating whether the specified date and time is within a daylight saving time period.
C# Syntax:
public virtual bool IsDaylightSavingTime(
   DateTime time
);
Parameters:

time

A date and time.

Return Value:
true if time is in a daylight saving time period; false otherwise, or if time is null.
Remarks
The year to which the daylight saving time period applies is derived from time.

Return to top


Overloaded Method: IsDaylightSavingTime(
   DateTime time,
   DaylightTime daylightTimes
)
Summary
Returns a value indicating whether the specified date and time is within the specified daylight saving time period.
C# Syntax:
public static bool IsDaylightSavingTime(
   DateTime time,
   DaylightTime daylightTimes
);
Parameters:

time

A date and time.

daylightTimes

A daylight saving time period.

Return Value:
true if time is in daylightTimes; otherwise, false.
Exceptions
Exception Type Condition
ArgumentNullException daylightTimes is null.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToLocalTime(
   DateTime time
)
Summary
Returns the local time that corresponds to a specified coordinated universal time (UTC).
C# Syntax:
public virtual DateTime ToLocalTime(
   DateTime time
);
Parameters:

time

A UTC time.

Return Value:
A DateTime instance whose value is the local time that corresponds to time.
Remarks
Coordinated universal time (UTC) was previously known as Greenwich Mean Time (GMT). Local time is the date and time on the computer you are using. Offset is the difference between local time and GMT. That is:

local time = UTC + offset

See also:
TimeZone.ToUniversalTime | TimeZone.GetUtcOffset

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToUniversalTime(
   DateTime time
)
Summary
Returns the coordinated universal time (UTC) that corresponds to a specified local time.
C# Syntax:
public virtual DateTime ToUniversalTime(
   DateTime time
);
Parameters:

time

The local date and time.

Return Value:
A DateTime instance whose value is the UTC time that corresponds to time.
Remarks
Coordinated universal time (UTC) was previously known as Greenwich Mean Time (GMT). Local time is the date and time on the computer you are using. Offset is the difference between local time and UTC. That is:

UTC = local time - offset

See also:
TimeZone.ToLocalTime | TimeZone.GetUtcOffset

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.