1a33f8fbdSAdrien Destugues/* 2820dca4dSJohn Scipione * Copyright 2011 Haiku, Inc. All rights reserved. 3820dca4dSJohn Scipione * Distributed under the terms of the MIT License. 4a33f8fbdSAdrien Destugues * 5820dca4dSJohn Scipione * Authors: 6820dca4dSJohn Scipione * Adrien Destugues, pulkomandy@pulkomandy.ath.cx 7820dca4dSJohn Scipione * John Scipione, jscipione@gmail.com 8820dca4dSJohn Scipione * Oliver Tappe, zooey@hirschkaefer.de 9820dca4dSJohn Scipione * 10a33f8fbdSAdrien Destugues * Corresponds to: 11820dca4dSJohn Scipione * headers/os/locale/TimeZone.h rev 42274 12820dca4dSJohn Scipione * src/kits/locale/TimeZone.cpp rev 42274 13a33f8fbdSAdrien Destugues */ 14a33f8fbdSAdrien Destugues 15a33f8fbdSAdrien Destugues 16a33f8fbdSAdrien Destugues/*! 17a33f8fbdSAdrien Destugues \file TimeZone.h 18820dca4dSJohn Scipione \ingroup locale 19820dca4dSJohn Scipione \ingroup libbe 20820dca4dSJohn Scipione \brief Provides the BTimeZone class. 21a33f8fbdSAdrien Destugues*/ 22a33f8fbdSAdrien Destugues 23a33f8fbdSAdrien Destugues 24a33f8fbdSAdrien Destugues/*! 25a33f8fbdSAdrien Destugues \class BTimeZone 26a33f8fbdSAdrien Destugues \ingroup locale 27820dca4dSJohn Scipione \ingroup libbe 28*71f6259aSJohn Scipione \brief Defines the time zone API which specifies a time zone, allows you to 29*71f6259aSJohn Scipione display it to the user, and converts between GMT and local time. 30*71f6259aSJohn Scipione 31*71f6259aSJohn Scipione When displaying the name of a time zone to the user, use the display name, 32*71f6259aSJohn Scipione not the time zone ID. The display name can be retrieved by the 33*71f6259aSJohn Scipione BTimeZone::Name(), BTimeZone::DaylightSavingName(), BTimeZone::ShortName(), 34*71f6259aSJohn Scipione and BTimeZone::ShortDaylightSavingName() methods. 35*71f6259aSJohn Scipione 36*71f6259aSJohn Scipione - The standard name looks like "Pacific Standard Time". 37*71f6259aSJohn Scipione - The daylight savings time name looks like "Pacific Daylight Time". 38*71f6259aSJohn Scipione - The short name looks like either "PST" or "PDT" depending on whether the 39*71f6259aSJohn Scipione standard or daylight savings time name is requested. 40*71f6259aSJohn Scipione 41*71f6259aSJohn Scipione \sa BTimeZone::ID() 42*71f6259aSJohn Scipione \sa BTimeZone::Name() 43*71f6259aSJohn Scipione \sa BTimeZone::DaylightSavingName() 44*71f6259aSJohn Scipione \sa BTimeZone::ShortName() 45*71f6259aSJohn Scipione \sa BTimeZone::ShortDaylightSavingName() 46edc845a3SJohn Scipione 47edc845a3SJohn Scipione \since Haiku R1 48a33f8fbdSAdrien Destugues*/ 49a33f8fbdSAdrien Destugues 50a33f8fbdSAdrien Destugues 51a33f8fbdSAdrien Destugues/*! 52a33f8fbdSAdrien Destugues \fn BTimeZone::BTimeZone(const char* zoneID, const BLanguage* language) 53a33f8fbdSAdrien Destugues \brief Construct a timezone from its \a zoneID and \a language. 54a33f8fbdSAdrien Destugues 55a33f8fbdSAdrien Destugues The constructor only allows you to construct a timezone if you already 56a33f8fbdSAdrien Destugues know its code. If you don't know the code, you can instead go through the 57a33f8fbdSAdrien Destugues BCountry class which can enumerate all timezones in a country, or use the 58a33f8fbdSAdrien Destugues BLocaleRoster, which knows the timezone selected by the user. 59edc845a3SJohn Scipione 60*71f6259aSJohn Scipione \param zoneID A time zone ID, for example, "America/Los_Angeles". 61*71f6259aSJohn Scipione This ID is used to call up a specific real-world time zone. 62*71f6259aSJohn Scipione \param language The \a language to use when displaying the time zone. 63*71f6259aSJohn Scipione 64edc845a3SJohn Scipione \since Haiku R1 65a33f8fbdSAdrien Destugues*/ 66a33f8fbdSAdrien Destugues 67a33f8fbdSAdrien Destugues 68a33f8fbdSAdrien Destugues/*! 69a33f8fbdSAdrien Destugues \fn BTimeZone::BTimeZone(const BTimeZone& other) 70*71f6259aSJohn Scipione \brief Copy constructor. 71*71f6259aSJohn Scipione 72*71f6259aSJohn Scipione \param other The BTimeZone object to copy from. 73edc845a3SJohn Scipione 74edc845a3SJohn Scipione \since Haiku R1 75a33f8fbdSAdrien Destugues*/ 76a33f8fbdSAdrien Destugues 77a33f8fbdSAdrien Destugues 78a33f8fbdSAdrien Destugues/*! 79a33f8fbdSAdrien Destugues \fn BTimeZone& BTimeZone::operator=(const BTimeZone& source) 80*71f6259aSJohn Scipione \brief Assignment operator. 81*71f6259aSJohn Scipione 82*71f6259aSJohn Scipione \param source The BTimeZone object to copy from. 83edc845a3SJohn Scipione 84edc845a3SJohn Scipione \since Haiku R1 85a33f8fbdSAdrien Destugues*/ 86a33f8fbdSAdrien Destugues 87a33f8fbdSAdrien Destugues 88a33f8fbdSAdrien Destugues/*! 89a33f8fbdSAdrien Destugues \fn const BString& BTimeZone::ID() const 90*71f6259aSJohn Scipione \brief Returns the ID of the time zone as a BString, for example, 91*71f6259aSJohn Scipione "America/Los_Angeles". 92*71f6259aSJohn Scipione 93*71f6259aSJohn Scipione When displaying the name of a time zone to the user, use the display name, 94*71f6259aSJohn Scipione not the time zone ID. 95edc845a3SJohn Scipione 96edc845a3SJohn Scipione \since Haiku R1 97a33f8fbdSAdrien Destugues*/ 98a33f8fbdSAdrien Destugues 99a33f8fbdSAdrien Destugues 100a33f8fbdSAdrien Destugues/*! 101a33f8fbdSAdrien Destugues \fn const BString& BTimeZone::Name() const 102*71f6259aSJohn Scipione \brief Returns the localized name of the time zone, for example 103*71f6259aSJohn Scipione "Pacific Standard Time". 104a33f8fbdSAdrien Destugues 105a33f8fbdSAdrien Destugues Use this method to display the time zone's name to the user. 106edc845a3SJohn Scipione 107edc845a3SJohn Scipione \since Haiku R1 108a33f8fbdSAdrien Destugues*/ 109a33f8fbdSAdrien Destugues 110a33f8fbdSAdrien Destugues 111a33f8fbdSAdrien Destugues/*! 112a33f8fbdSAdrien Destugues \fn const BString& BTimeZone::DaylightSavingName() const 113*71f6259aSJohn Scipione \brief Returns the localized daylight savings name of the time zone, 114*71f6259aSJohn Scipione for example "Pacific Daylight Time". 115edc845a3SJohn Scipione 116edc845a3SJohn Scipione \since Haiku R1 117a33f8fbdSAdrien Destugues*/ 118a33f8fbdSAdrien Destugues 119a33f8fbdSAdrien Destugues 120a33f8fbdSAdrien Destugues/*! 121a33f8fbdSAdrien Destugues \fn const BString& BTimeZone::ShortName() const 122*71f6259aSJohn Scipione \brief Returns the short name of the timezone, in the user's locale, 123*71f6259aSJohn Scipione for example "PST". 124edc845a3SJohn Scipione 125edc845a3SJohn Scipione \since Haiku R1 126a33f8fbdSAdrien Destugues*/ 127a33f8fbdSAdrien Destugues 128a33f8fbdSAdrien Destugues 129a33f8fbdSAdrien Destugues/*! 130a33f8fbdSAdrien Destugues \fn const BString& BTimeZone::ShortDaylightSavingName() const 131*71f6259aSJohn Scipione \brief Returns the localized daylight savings name of the time zone, 132*71f6259aSJohn Scipione for example "PDT". 133edc845a3SJohn Scipione 134edc845a3SJohn Scipione \since Haiku R1 135a33f8fbdSAdrien Destugues*/ 136a33f8fbdSAdrien Destugues 137a33f8fbdSAdrien Destugues 138a33f8fbdSAdrien Destugues/*! 139a33f8fbdSAdrien Destugues \fn int BTimeZone::OffsetFromGMT() const 140*71f6259aSJohn Scipione \brief Returns the offset, in milliseconds, between the standard time 141*71f6259aSJohn Scipione of a time zone and GMT. 142a33f8fbdSAdrien Destugues 143*71f6259aSJohn Scipione Positive raw offsets are east of Greenwich, negative offsets are west of 144*71f6259aSJohn Scipione Greenwich. 145*71f6259aSJohn Scipione 146*71f6259aSJohn Scipione \return The offset as a number of milliseconds from GMT, positive 147*71f6259aSJohn Scipione or negative. 148edc845a3SJohn Scipione 149edc845a3SJohn Scipione \since Haiku R1 150a33f8fbdSAdrien Destugues*/ 151a33f8fbdSAdrien Destugues 152a33f8fbdSAdrien Destugues 153a33f8fbdSAdrien Destugues/*! 154a33f8fbdSAdrien Destugues \fn bool BTimeZone::SupportsDaylightSaving() const 155*71f6259aSJohn Scipione \brief Returns whether or not if the time zone support daylight saving time. 156*71f6259aSJohn Scipione 157*71f6259aSJohn Scipione \return \c true if the time zone supports daylight savings time, 158*71f6259aSJohn Scipione \c false otherwise. 159edc845a3SJohn Scipione 160edc845a3SJohn Scipione \since Haiku R1 161a33f8fbdSAdrien Destugues*/ 162a33f8fbdSAdrien Destugues 163a33f8fbdSAdrien Destugues 164a33f8fbdSAdrien Destugues/*! 165a33f8fbdSAdrien Destugues \fn status_t BTimeZone::InitCheck() const 166*71f6259aSJohn Scipione \brief Returns whether or not the constructor initialized the time zone. 167*71f6259aSJohn Scipione 168*71f6259aSJohn Scipione \return \c true if BTimeZone object was initialized successfully, \c false 169*71f6259aSJohn Scipione if there was an error initializing the BTimeZone, for instance if the 170*71f6259aSJohn Scipione constructor or SetTo() was called with an invalid timezone ID. 171edc845a3SJohn Scipione 172edc845a3SJohn Scipione \since Haiku R1 173a33f8fbdSAdrien Destugues*/ 174a33f8fbdSAdrien Destugues 175a33f8fbdSAdrien Destugues 176a33f8fbdSAdrien Destugues/*! 1776ec9625aSAdrien Destugues \fn status_t BTimeZone::SetTo(const char* zoneCode, 178*71f6259aSJohn Scipione const BLanguage* language) 179*71f6259aSJohn Scipione \brief Set the BTimeZone object to use a different time zone. 180a33f8fbdSAdrien Destugues 181*71f6259aSJohn Scipione \param zoneCode The time zone ID to use, for example "America/Los_Angeles". 182*71f6259aSJohn Scipione \param language The \a language to use when displaying the time zone. 183*71f6259aSJohn Scipione 184*71f6259aSJohn Scipione \return \c true if time zone was set successfully, \c false if there was an 185*71f6259aSJohn Scipione error setting the time zone, for instance if this method was called 186*71f6259aSJohn Scipione using an invalid \a zoneCode. 187edc845a3SJohn Scipione 188edc845a3SJohn Scipione \since Haiku R1 189a33f8fbdSAdrien Destugues*/ 190