Logo Search packages:      
Sourcecode: icu version File versions  Download package

TimeZone Class Reference

#include <timezone.h>

Inheritance diagram for TimeZone:

UObject UMemory BasicTimeZone OlsonTimeZone RuleBasedTimeZone SimpleTimeZone VTimeZone

List of all members.


Detailed Description

TimeZone represents a time zone offset, and also figures out daylight savings.

Typically, you get a TimeZone using createDefault which creates a TimeZone based on the time zone where the program is running. For example, for a program running in Japan, createDefault creates a TimeZone object based on Japanese Standard Time.

You can also get a TimeZone using createTimeZone along with a time zone ID. For instance, the time zone ID for the US Pacific Time zone is "America/Los_Angeles". So, you can get a Pacific Time TimeZone object with:

 TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles");
 
You can use getAvailableIDs method to iterate through all the supported time zone IDs. You can then choose a supported ID to get a TimeZone. If the time zone you want is not represented by one of the supported IDs, then you can create a custom time zone ID with the following syntax:

 GMT[+|-]hh[[:]mm]
 

For example, you might specify GMT+14:00 as a custom time zone ID. The TimeZone that is returned when you specify a custom time zone ID does not include daylight savings time.

TimeZone is an abstract class representing a time zone. A TimeZone is needed for Calendar to produce local time for a particular time zone. A TimeZone comprises three basic pieces of information:

(Only the ID is actually implemented in TimeZone; subclasses of TimeZone may handle daylight savings time and GMT offset in different ways. Currently we only have one TimeZone subclass: SimpleTimeZone.)

The TimeZone class contains a static list containing a TimeZone object for every combination of GMT offset and daylight-savings time rules currently in use in the world, each with a unique ID. Each ID consists of a region (usually a continent or ocean) and a city in that region, separated by a slash, (for example, US Pacific Time is "America/Los_Angeles.") Because older versions of this class used three- or four-letter abbreviations instead, there is also a table that maps the older abbreviations to the newer ones (for example, "PST" maps to "America/Los_Angeles"). Anywhere the API requires an ID, you can use either form.

To create a new TimeZone, you call the factory function TimeZone::createTimeZone() and pass it a time zone ID. You can use the createEnumeration() function to obtain a list of all the time zone IDs recognized by createTimeZone().

You can also use TimeZone::createDefault() to create a TimeZone. This function uses platform-specific APIs to produce a TimeZone for the time zone corresponding to the client's computer's physical location. For example, if you're in Japan (assuming your machine is set up correctly), TimeZone::createDefault() will return a TimeZone for Japanese Standard Time ("Asia/Tokyo").

Definition at line 122 of file timezone.h.


Public Types

enum  EDisplayType { SHORT = 1, LONG }

Public Member Functions

virtual TimeZoneclone (void) const =0
UnicodeStringgetDisplayName (UBool daylight, EDisplayType style, const Locale &locale, UnicodeString &result) const
UnicodeStringgetDisplayName (UBool daylight, EDisplayType style, UnicodeString &result) const
UnicodeStringgetDisplayName (const Locale &locale, UnicodeString &result) const
UnicodeStringgetDisplayName (UnicodeString &result) const
virtual int32_t getDSTSavings () const
virtual UClassID getDynamicClassID (void) const =0
UnicodeStringgetID (UnicodeString &ID) const
virtual void getOffset (UDate date, UBool local, int32_t &rawOffset, int32_t &dstOffset, UErrorCode &ec) const
virtual int32_t getOffset (uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t milliseconds, int32_t monthLength, UErrorCode &status) const =0
virtual int32_t getOffset (uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t millis, UErrorCode &status) const =0
virtual int32_t getRawOffset (void) const =0
virtual UBool hasSameRules (const TimeZone &other) const
virtual UBool inDaylightTime (UDate date, UErrorCode &status) const =0
UBool operator!= (const TimeZone &that) const
virtual UBool operator== (const TimeZone &that) const
void setID (const UnicodeString &ID)
virtual void setRawOffset (int32_t offsetMillis)=0
virtual UBool useDaylightTime (void) const =0
virtual ~TimeZone ()

Static Public Member Functions

static void U_EXPORT2 adoptDefault (TimeZone *zone)
static int32_t U_EXPORT2 countEquivalentIDs (const UnicodeString &id)
static TimeZone *U_EXPORT2 createDefault (void)
static StringEnumeration *U_EXPORT2 createEnumeration (const char *country)
static StringEnumeration *U_EXPORT2 createEnumeration (int32_t rawOffset)
static StringEnumeration *U_EXPORT2 createEnumeration ()
static TimeZone *U_EXPORT2 createTimeZone (const UnicodeString &ID)
static UnicodeString &U_EXPORT2 getCanonicalID (const UnicodeString &id, UnicodeString &canonicalID, UBool &isSystemID, UErrorCode &status)
static UnicodeString &U_EXPORT2 getCanonicalID (const UnicodeString &id, UnicodeString &canonicalID, UErrorCode &status)
static const UnicodeString
U_EXPORT2 
getEquivalentID (const UnicodeString &id, int32_t index)
static const TimeZone *U_EXPORT2 getGMT (void)
static UClassID U_EXPORT2 getStaticClassID (void)
static const char *U_EXPORT2 getTZDataVersion (UErrorCode &status)
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW
static void U_EXPORT2 setDefault (const TimeZone &zone)

Protected Member Functions

TimeZoneoperator= (const TimeZone &right)
 TimeZone (const TimeZone &source)
 TimeZone (const UnicodeString &id)
 TimeZone ()

Static Protected Member Functions

static UResourceBundleloadRule (const UResourceBundle *top, const UnicodeString &ruleid, UResourceBundle *oldbundle, UErrorCode &status)

Static Private Member Functions

static TimeZonecreateCustomTimeZone (const UnicodeString &)
static TimeZonecreateSystemTimeZone (const UnicodeString &name)
static UnicodeStringdereferOlsonLink (const UnicodeString &linkTo, UnicodeString &linkFrom)
static UnicodeStringformatCustomID (int32_t hour, int32_t min, int32_t sec, UBool negative, UnicodeString &id)
static UnicodeStringgetCustomID (const UnicodeString &id, UnicodeString &normalized, UErrorCode &status)
static void initDefault (void)
static UBool parseCustomID (const UnicodeString &id, int32_t &sign, int32_t &hour, int32_t &min, int32_t &sec)

Private Attributes

UnicodeString fID

Friends

class ZoneMeta

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index