Loading...
Searching...
No Matches
Public Member Functions | List of all members
BTimeZone Class Reference

Defines the time zone API which specifies a time zone, allows you to display it to the user, and converts between GMT and local time. More...

Public Member Functions

 BTimeZone (const BTimeZone &other)
 Copy constructor.
 
 BTimeZone (const char *zoneID=NULL, const BLanguage *language=NULL)
 Construct a timezone from its zoneID and language.
 
const BStringDaylightSavingName () const
 Returns the localized daylight savings name of the time zone, for example "Pacific Daylight Time".
 
const BStringID () const
 Returns the ID of the time zone as a BString, for example, "America/Los_Angeles".
 
status_t InitCheck () const
 Returns whether or not the constructor initialized the time zone.
 
const BStringName () const
 Returns the localized name of the time zone, for example "Pacific Standard Time".
 
int OffsetFromGMT () const
 Returns the offset, in milliseconds, between the standard time of a time zone and GMT.
 
BTimeZoneoperator= (const BTimeZone &source)
 Assignment operator.
 
status_t SetTo (const char *zoneID, const BLanguage *language=NULL)
 Set the BTimeZone object to use a different time zone.
 
const BStringShortDaylightSavingName () const
 Returns the localized daylight savings name of the time zone, for example "PDT".
 
const BStringShortName () const
 Returns the short name of the timezone, in the user's locale, for example "PST".
 
bool SupportsDaylightSaving () const
 Returns whether or not if the time zone support daylight saving time.
 

Detailed Description

Defines the time zone API which specifies a time zone, allows you to display it to the user, and converts between GMT and local time.

When displaying the name of a time zone to the user, use the display name, not the time zone ID. The display name can be retrieved by the BTimeZone::Name(), BTimeZone::DaylightSavingName(), BTimeZone::ShortName(), and BTimeZone::ShortDaylightSavingName() methods.

See also
BTimeZone::ID()
BTimeZone::Name()
BTimeZone::DaylightSavingName()
BTimeZone::ShortName()
BTimeZone::ShortDaylightSavingName()
Since
Haiku R1

Constructor & Destructor Documentation

◆ BTimeZone() [1/2]

BTimeZone::BTimeZone ( const char *  zoneID = NULL,
const BLanguage *  language = NULL 
)

Construct a timezone from its zoneID and language.

The constructor only allows you to construct a timezone if you already know its code. If you don't know the code, you can instead go through the BCountry class which can enumerate all timezones in a country, or use the BLocaleRoster, which knows the timezone selected by the user.

Parameters
zoneIDA time zone ID, for example, "America/Los_Angeles". This ID is used to call up a specific real-world time zone.
languageThe language to use when displaying the time zone.
Since
Haiku R1

◆ BTimeZone() [2/2]

BTimeZone::BTimeZone ( const BTimeZone other)

Copy constructor.

Parameters
otherThe BTimeZone object to copy from.
Since
Haiku R1

Member Function Documentation

◆ DaylightSavingName()

const BString & BTimeZone::DaylightSavingName ( ) const

Returns the localized daylight savings name of the time zone, for example "Pacific Daylight Time".

Since
Haiku R1

◆ ID()

const BString & BTimeZone::ID ( ) const

Returns the ID of the time zone as a BString, for example, "America/Los_Angeles".

When displaying the name of a time zone to the user, use the display name, not the time zone ID.

Since
Haiku R1

◆ InitCheck()

status_t BTimeZone::InitCheck ( ) const

Returns whether or not the constructor initialized the time zone.

Returns
true if BTimeZone object was initialized successfully, false if there was an error initializing the BTimeZone, for instance if the constructor or SetTo() was called with an invalid timezone ID.
Since
Haiku R1

◆ Name()

const BString & BTimeZone::Name ( ) const

Returns the localized name of the time zone, for example "Pacific Standard Time".

Use this method to display the time zone's name to the user.

Since
Haiku R1

◆ OffsetFromGMT()

int BTimeZone::OffsetFromGMT ( ) const

Returns the offset, in milliseconds, between the standard time of a time zone and GMT.

Positive raw offsets are east of Greenwich, negative offsets are west of Greenwich.

Returns
The offset as a number of milliseconds from GMT, positive or negative.
Since
Haiku R1

◆ operator=()

BTimeZone & BTimeZone::operator= ( const BTimeZone source)

Assignment operator.

Parameters
sourceThe BTimeZone object to copy from.
Since
Haiku R1

◆ SetTo()

status_t BTimeZone::SetTo ( const char *  zoneCode,
const BLanguage *  language = NULL 
)

Set the BTimeZone object to use a different time zone.

Parameters
zoneCodeThe time zone ID to use, for example "America/Los_Angeles".
languageThe language to use when displaying the time zone.
Returns
true if time zone was set successfully, false if there was an error setting the time zone, for instance if this method was called using an invalid zoneCode.
Since
Haiku R1

◆ ShortDaylightSavingName()

const BString & BTimeZone::ShortDaylightSavingName ( ) const

Returns the localized daylight savings name of the time zone, for example "PDT".

Since
Haiku R1

◆ ShortName()

const BString & BTimeZone::ShortName ( ) const

Returns the short name of the timezone, in the user's locale, for example "PST".

Since
Haiku R1

◆ SupportsDaylightSaving()

bool BTimeZone::SupportsDaylightSaving ( ) const

Returns whether or not if the time zone support daylight saving time.

Returns
true if the time zone supports daylight savings time, false otherwise.
Since
Haiku R1