mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-5454 Fix newline settings for new code.
X-SVN-Rev: 21851
This commit is contained in:
parent
915e631e92
commit
78c96b07fa
15 changed files with 7329 additions and 7342 deletions
14
.gitattributes
vendored
14
.gitattributes
vendored
|
@ -126,22 +126,8 @@ icu4c/source/data/xml/main/nr.xml -text
|
|||
icu4c/source/data/xml/main/pa_Guru.xml -text
|
||||
icu4c/source/data/xml/main/tl.xml -text
|
||||
icu4c/source/data/xml/main/to.xml -text
|
||||
icu4c/source/i18n/basictz.cpp -text
|
||||
icu4c/source/i18n/dtrule.cpp -text
|
||||
icu4c/source/i18n/persncal.cpp -text
|
||||
icu4c/source/i18n/persncal.h -text
|
||||
icu4c/source/i18n/rbtz.cpp -text
|
||||
icu4c/source/i18n/reldtfmt.cpp -text
|
||||
icu4c/source/i18n/reldtfmt.h -text
|
||||
icu4c/source/i18n/tzrule.cpp -text
|
||||
icu4c/source/i18n/tztrans.cpp -text
|
||||
icu4c/source/i18n/unicode/basictz.h -text
|
||||
icu4c/source/i18n/unicode/dtrule.h -text
|
||||
icu4c/source/i18n/unicode/rbtz.h -text
|
||||
icu4c/source/i18n/unicode/tzrule.h -text
|
||||
icu4c/source/i18n/unicode/tztrans.h -text
|
||||
icu4c/source/i18n/unicode/vtzone.h -text
|
||||
icu4c/source/i18n/vtzone.cpp -text
|
||||
icu4c/source/samples/layout/cgnomelayout.c -text
|
||||
icu4c/source/samples/layout/gnomeglue.cpp -text
|
||||
icu4c/source/samples/layout/gnomeglue.h -text
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,139 +1,137 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/dtrule.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule)
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t dayOfMonth,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: UObject(),
|
||||
fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay),
|
||||
fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) {
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t weekInMonth,
|
||||
int32_t dayOfWeek,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: UObject(),
|
||||
fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay),
|
||||
fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) {
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t dayOfMonth,
|
||||
int32_t dayOfWeek,
|
||||
UBool after,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: UObject(),
|
||||
fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay),
|
||||
fTimeRuleType(timeType) {
|
||||
if (after) {
|
||||
fDateRuleType = DateTimeRule::DOW_GEQ_DOM;
|
||||
} else {
|
||||
fDateRuleType = DateTimeRule::DOW_LEQ_DOM;
|
||||
}
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(const DateTimeRule& source)
|
||||
: UObject(source),
|
||||
fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek),
|
||||
fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay),
|
||||
fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) {
|
||||
}
|
||||
|
||||
DateTimeRule::~DateTimeRule() {
|
||||
}
|
||||
|
||||
DateTimeRule*
|
||||
DateTimeRule::clone() const {
|
||||
return new DateTimeRule(*this);
|
||||
}
|
||||
|
||||
DateTimeRule&
|
||||
DateTimeRule::operator=(const DateTimeRule& right) {
|
||||
if (this != &right) {
|
||||
fMonth = right.fMonth;
|
||||
fDayOfMonth = right.fDayOfMonth;
|
||||
fDayOfWeek = right.fDayOfWeek;
|
||||
fWeekInMonth = right.fWeekInMonth;
|
||||
fMillisInDay = right.fMillisInDay;
|
||||
fDateRuleType = right.fDateRuleType;
|
||||
fTimeRuleType = right.fTimeRuleType;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
UBool
|
||||
DateTimeRule::operator==(const DateTimeRule& that) const {
|
||||
return ((this == &that) ||
|
||||
(getDynamicClassID() == that.getDynamicClassID() &&
|
||||
fMonth == that.fMonth &&
|
||||
fDayOfMonth == that.fDayOfMonth &&
|
||||
fDayOfWeek == that.fDayOfWeek &&
|
||||
fWeekInMonth == that.fWeekInMonth &&
|
||||
fMillisInDay == that.fMillisInDay &&
|
||||
fDateRuleType == that.fDateRuleType &&
|
||||
fTimeRuleType == that.fTimeRuleType));
|
||||
}
|
||||
|
||||
UBool
|
||||
DateTimeRule::operator!=(const DateTimeRule& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
DateTimeRule::DateRuleType
|
||||
DateTimeRule::getDateRuleType(void) const {
|
||||
return fDateRuleType;
|
||||
}
|
||||
|
||||
DateTimeRule::TimeRuleType
|
||||
DateTimeRule::getTimeRuleType(void) const {
|
||||
return fTimeRuleType;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleMonth(void) const {
|
||||
return fMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleDayOfMonth(void) const {
|
||||
return fDayOfMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleDayOfWeek(void) const {
|
||||
return fDayOfWeek;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleWeekInMonth(void) const {
|
||||
return fWeekInMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleMillisInDay(void) const {
|
||||
return fMillisInDay;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/dtrule.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(DateTimeRule)
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t dayOfMonth,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(0), fWeekInMonth(0), fMillisInDay(millisInDay),
|
||||
fDateRuleType(DateTimeRule::DOM), fTimeRuleType(timeType) {
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t weekInMonth,
|
||||
int32_t dayOfWeek,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: fMonth(month), fDayOfMonth(0), fDayOfWeek(dayOfWeek), fWeekInMonth(weekInMonth), fMillisInDay(millisInDay),
|
||||
fDateRuleType(DateTimeRule::DOW), fTimeRuleType(timeType) {
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(int32_t month,
|
||||
int32_t dayOfMonth,
|
||||
int32_t dayOfWeek,
|
||||
UBool after,
|
||||
int32_t millisInDay,
|
||||
TimeRuleType timeType)
|
||||
: UObject(),
|
||||
fMonth(month), fDayOfMonth(dayOfMonth), fDayOfWeek(dayOfWeek), fWeekInMonth(0), fMillisInDay(millisInDay),
|
||||
fTimeRuleType(timeType) {
|
||||
if (after) {
|
||||
fDateRuleType = DateTimeRule::DOW_GEQ_DOM;
|
||||
} else {
|
||||
fDateRuleType = DateTimeRule::DOW_LEQ_DOM;
|
||||
}
|
||||
}
|
||||
|
||||
DateTimeRule::DateTimeRule(const DateTimeRule& source)
|
||||
: UObject(source),
|
||||
fMonth(source.fMonth), fDayOfMonth(source.fDayOfMonth), fDayOfWeek(source.fDayOfWeek),
|
||||
fWeekInMonth(source.fWeekInMonth), fMillisInDay(source.fMillisInDay),
|
||||
fDateRuleType(source.fDateRuleType), fTimeRuleType(source.fTimeRuleType) {
|
||||
}
|
||||
|
||||
DateTimeRule::~DateTimeRule() {
|
||||
}
|
||||
|
||||
DateTimeRule*
|
||||
DateTimeRule::clone() const {
|
||||
return new DateTimeRule(*this);
|
||||
}
|
||||
|
||||
DateTimeRule&
|
||||
DateTimeRule::operator=(const DateTimeRule& right) {
|
||||
if (this != &right) {
|
||||
fMonth = right.fMonth;
|
||||
fDayOfMonth = right.fDayOfMonth;
|
||||
fDayOfWeek = right.fDayOfWeek;
|
||||
fWeekInMonth = right.fWeekInMonth;
|
||||
fMillisInDay = right.fMillisInDay;
|
||||
fDateRuleType = right.fDateRuleType;
|
||||
fTimeRuleType = right.fTimeRuleType;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
UBool
|
||||
DateTimeRule::operator==(const DateTimeRule& that) const {
|
||||
return ((this == &that) ||
|
||||
(getDynamicClassID() == that.getDynamicClassID() &&
|
||||
fMonth == that.fMonth &&
|
||||
fDayOfMonth == that.fDayOfMonth &&
|
||||
fDayOfWeek == that.fDayOfWeek &&
|
||||
fWeekInMonth == that.fWeekInMonth &&
|
||||
fMillisInDay == that.fMillisInDay &&
|
||||
fDateRuleType == that.fDateRuleType &&
|
||||
fTimeRuleType == that.fTimeRuleType));
|
||||
}
|
||||
|
||||
UBool
|
||||
DateTimeRule::operator!=(const DateTimeRule& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
DateTimeRule::DateRuleType
|
||||
DateTimeRule::getDateRuleType(void) const {
|
||||
return fDateRuleType;
|
||||
}
|
||||
|
||||
DateTimeRule::TimeRuleType
|
||||
DateTimeRule::getTimeRuleType(void) const {
|
||||
return fTimeRuleType;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleMonth(void) const {
|
||||
return fMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleDayOfMonth(void) const {
|
||||
return fDayOfMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleDayOfWeek(void) const {
|
||||
return fDayOfWeek;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleWeekInMonth(void) const {
|
||||
return fWeekInMonth;
|
||||
}
|
||||
|
||||
int32_t
|
||||
DateTimeRule::getRuleMillisInDay(void) const {
|
||||
return fMillisInDay;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
//eof
|
||||
|
|
|
@ -1,392 +1,392 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2007, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*
|
||||
* File PERSNCAL.CPP
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 9/23/2003 mehran posted to icu-design
|
||||
*****************************************************************************
|
||||
*/
|
||||
#include "persncal.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
static const int monthDays[] = { 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 };
|
||||
|
||||
static int32_t
|
||||
jalali_to_julian(int year, int month, int day)
|
||||
{
|
||||
int32_t daysNo=0;
|
||||
int i;
|
||||
|
||||
year = year -475+2820;
|
||||
month -= 1;
|
||||
|
||||
daysNo=(year/2820)*1029983;
|
||||
year=year % 2820;
|
||||
|
||||
daysNo+=(year/128)* 46751;
|
||||
if((year/128)>21)
|
||||
{
|
||||
daysNo-=46751;
|
||||
year=(year%128)+128;
|
||||
}
|
||||
else
|
||||
year=year%128;
|
||||
|
||||
if(year>=29)
|
||||
{
|
||||
year-=29;
|
||||
daysNo+=10592;
|
||||
}
|
||||
|
||||
if(year>=66)
|
||||
{
|
||||
year-=66;
|
||||
daysNo+=24106;
|
||||
}
|
||||
else if( year>=33)
|
||||
{
|
||||
daysNo+=(year/33)* 12053;
|
||||
year=year%33;
|
||||
}
|
||||
|
||||
if (year >= 5)
|
||||
{
|
||||
daysNo += 1826;
|
||||
year -=5;
|
||||
}
|
||||
else if (year == 4)
|
||||
{
|
||||
daysNo += 1460;
|
||||
year -=4;
|
||||
}
|
||||
|
||||
daysNo += 1461 * (year/4);
|
||||
year %= 4;
|
||||
daysNo += 365 * year;
|
||||
|
||||
for (i = 0; i < month; i++) {
|
||||
daysNo += monthDays[i];
|
||||
}
|
||||
|
||||
daysNo += day;
|
||||
|
||||
return daysNo-856493;
|
||||
}
|
||||
|
||||
static void julian_to_jalali (int32_t daysNo, int *h_y, int *h_m, int *h_d)
|
||||
{
|
||||
int year=0, month=0, day=0,scalarDays=0;
|
||||
int i;
|
||||
|
||||
daysNo+=856493;
|
||||
scalarDays=daysNo;
|
||||
year=(daysNo/1029983)*2820;
|
||||
daysNo=daysNo%1029983;
|
||||
|
||||
if((daysNo/46751)<=21)
|
||||
{
|
||||
year+=(daysNo/46751)* 128;
|
||||
daysNo=daysNo%46751;
|
||||
}
|
||||
else
|
||||
{
|
||||
year+=(daysNo/46751)* 128;
|
||||
daysNo=daysNo%46751;
|
||||
year-=128;
|
||||
daysNo+=46751;
|
||||
}
|
||||
|
||||
if (daysNo >= 10592)
|
||||
{
|
||||
year+= 29;
|
||||
daysNo -= 10592;
|
||||
}
|
||||
|
||||
if(daysNo>=24106)
|
||||
{
|
||||
daysNo-=24106;
|
||||
year+=66;
|
||||
}
|
||||
|
||||
if(daysNo>=12053)
|
||||
{
|
||||
daysNo-=12053;
|
||||
year+=33;
|
||||
}
|
||||
|
||||
|
||||
if (daysNo >= 1826)
|
||||
{
|
||||
year+= 5;
|
||||
daysNo -= 1826;
|
||||
}
|
||||
else if (daysNo > 1095)
|
||||
{
|
||||
year+= 3;
|
||||
daysNo -= 1095;
|
||||
|
||||
}
|
||||
|
||||
year +=(4 * (daysNo/1461));
|
||||
daysNo %= 1461;
|
||||
|
||||
if (daysNo == 0)
|
||||
{
|
||||
year -= 1;
|
||||
daysNo = 366;
|
||||
}
|
||||
else
|
||||
{
|
||||
year += daysNo/365;
|
||||
daysNo = daysNo % 365;
|
||||
if (daysNo == 0)
|
||||
{
|
||||
year -= 1;
|
||||
daysNo = 365;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < 11 && daysNo > monthDays[i]; ++i) {
|
||||
daysNo -= monthDays[i];
|
||||
}
|
||||
|
||||
month = i + 1;
|
||||
|
||||
day = daysNo;
|
||||
|
||||
*h_d = day;
|
||||
*h_m = month;
|
||||
*h_y = year-2345;
|
||||
}
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Implementation of the PersianCalendar class
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Constructors...
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
const char *PersianCalendar::getType() const {
|
||||
return "persian";
|
||||
}
|
||||
|
||||
Calendar* PersianCalendar::clone() const {
|
||||
return new PersianCalendar(*this);
|
||||
}
|
||||
|
||||
PersianCalendar::PersianCalendar(const Locale& aLocale, UErrorCode& success)
|
||||
: Calendar(TimeZone::createDefault(), aLocale, success)
|
||||
{
|
||||
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
|
||||
}
|
||||
|
||||
PersianCalendar::PersianCalendar(const PersianCalendar& other) : Calendar(other) {
|
||||
}
|
||||
|
||||
PersianCalendar::~PersianCalendar()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Minimum / Maximum access functions
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
|
||||
// Minimum Greatest Least Maximum
|
||||
// Minimum Maximum
|
||||
{ 0, 0, 0, 0 }, // ERA
|
||||
{ -2500, -2500, 2500, 2500 }, // YEAR
|
||||
{ 0, 0, 11, 11 }, // MONTH
|
||||
{ 1, 1, 52, 53 }, // WEEK_OF_YEAR
|
||||
{ 0, 0, 5, 6 }, // WEEK_OF_MONTH
|
||||
{ 1, 1, 29, 31 }, // DAY_OF_MONTH
|
||||
{ 1, 1, 365, 366 }, // DAY_OF_YEAR
|
||||
{ 0, 0, 6, 6 }, // DAY_OF_WEEK
|
||||
{ 1, 1, 4, 6 }, // DAY_OF_WEEK_IN_MONTH
|
||||
{ 0, 0, 1, 1 }, // AM_PM
|
||||
{ 0, 0, 11, 11 }, // HOUR
|
||||
{ 0, 0, 23, 23 }, // HOUR_OF_DAY
|
||||
{ 0, 0, 59, 59 }, // MINUTE
|
||||
{ 0, 0, 59, 59 }, // SECOND
|
||||
{ 0, 0, 999, 999 }, // MILLISECOND
|
||||
{ -12, -12, 12, 12 }, // ZONE_OFFSET
|
||||
{ 0, 0, 1, 1 }, // DST_OFFSET
|
||||
{ -140742, -140742, 144683, 140742 }, // YEAR_WOY
|
||||
{ 0, 0, 6, 6 }, // DOW_LOCAL
|
||||
{ -2500, -2500, 2500, 2500 }, // EXTENDED_YEAR
|
||||
{/* -1, -1, -1, -1 */}, // JULIAN_DAY
|
||||
{/* -1, -1, -1, -1 */}, // MILLISECONDS_IN_DAY
|
||||
};
|
||||
static const int32_t MONTH_COUNT[12][4] = {
|
||||
//len len2 st st2
|
||||
{ 31, 31, 0, 0 }, // Farvardin
|
||||
{ 31, 31, 31, 31 }, // Ordibehesht
|
||||
{ 31, 31, 62, 62 }, // Khordad
|
||||
{ 31, 31, 93, 93 }, // Tir
|
||||
{ 31, 31, 124, 124 }, // Mordad
|
||||
{ 31, 31, 155, 155 }, // Shahrivar
|
||||
{ 30, 30, 186, 186 }, // Mehr
|
||||
{ 30, 30, 216, 216 }, // Aban
|
||||
{ 30, 30, 246, 246 }, // Azar
|
||||
{ 30, 30, 276, 276 }, // Dey
|
||||
{ 30, 30, 306, 306 }, // Bahman
|
||||
{ 29, 30, 336, 336 } // Esfand
|
||||
// len length of month
|
||||
// len2 length of month in a leap year
|
||||
// st days in year before start of month
|
||||
// st2 days in year before month in leap year
|
||||
};
|
||||
|
||||
int32_t PersianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const {
|
||||
return LIMITS[field][limitType];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Assorted calculation utilities
|
||||
//
|
||||
|
||||
/**
|
||||
* Determine whether a year is a leap year in the Persian calendar
|
||||
*/
|
||||
UBool PersianCalendar::isLeapYear(int32_t year)
|
||||
{
|
||||
return jalali_to_julian(year+1,1,1)-jalali_to_julian(year,1,1) == 366;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the day # on which the given year starts. Days are counted
|
||||
* from the Hijri epoch, origin 0.
|
||||
*/
|
||||
int32_t PersianCalendar::yearStart(int32_t year) {
|
||||
return handleComputeMonthStart(year,1,FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the day # on which the given month starts. Days are counted
|
||||
* from the Hijri epoch, origin 0.
|
||||
*
|
||||
* @param year The hijri shamsi year
|
||||
* @param year The hijri shamsi month, 0-based
|
||||
*/
|
||||
int32_t PersianCalendar::monthStart(int32_t year, int32_t month) const {
|
||||
return handleComputeMonthStart(year,month,FALSE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Calendar framework
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the length (in days) of the given month.
|
||||
*
|
||||
* @param year The hijri shamsi year
|
||||
* @param year The hijri shamsi month, 0-based
|
||||
*/
|
||||
int32_t PersianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
|
||||
return MONTH_COUNT[month][PersianCalendar::isLeapYear(extendedYear)?1:0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of days in the given Persian year
|
||||
*/
|
||||
int32_t PersianCalendar::handleGetYearLength(int32_t extendedYear) const {
|
||||
return 365 + (PersianCalendar::isLeapYear(extendedYear) ? 1 : 0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Functions for converting from field values to milliseconds....
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Return JD of start of given month/year
|
||||
int32_t PersianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const {
|
||||
// If the month is out of range, adjust it into range, and
|
||||
// modify the extended year value accordingly.
|
||||
if (month < 0 || month > 11) {
|
||||
eyear += month / 12;
|
||||
month = month % 12;
|
||||
}
|
||||
return jalali_to_julian(eyear,(useMonth?month+1:1),1)-1+1947955;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Functions for converting from milliseconds to field values
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
int32_t PersianCalendar::handleGetExtendedYear() {
|
||||
int32_t year;
|
||||
if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
|
||||
year = internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
|
||||
} else {
|
||||
year = internalGet(UCAL_YEAR, 1); // Default to year 1
|
||||
}
|
||||
return year;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override Calendar to compute several fields specific to the Persian
|
||||
* calendar system. These are:
|
||||
*
|
||||
* <ul><li>ERA
|
||||
* <li>YEAR
|
||||
* <li>MONTH
|
||||
* <li>DAY_OF_MONTH
|
||||
* <li>DAY_OF_YEAR
|
||||
* <li>EXTENDED_YEAR</ul>
|
||||
*
|
||||
* The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
|
||||
* method is called. The getGregorianXxx() methods return Gregorian
|
||||
* calendar equivalents for the given Julian day.
|
||||
*/
|
||||
void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/) {
|
||||
int jy,jm,jd;
|
||||
julian_to_jalali(julianDay-1947955,&jy,&jm,&jd);
|
||||
internalSet(UCAL_ERA, 0);
|
||||
internalSet(UCAL_YEAR, jy);
|
||||
internalSet(UCAL_EXTENDED_YEAR, jy);
|
||||
internalSet(UCAL_MONTH, jm-1);
|
||||
internalSet(UCAL_DAY_OF_MONTH, jd);
|
||||
internalSet(UCAL_DAY_OF_YEAR, jd + MONTH_COUNT[jm-1][2]);
|
||||
}
|
||||
|
||||
UBool
|
||||
PersianCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return FALSE;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((PersianCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
|
||||
}
|
||||
|
||||
UBool PersianCalendar::haveDefaultCentury() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UDate PersianCalendar::defaultCenturyStart() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t PersianCalendar::defaultCenturyStartYear() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PersianCalendar)
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (C) 2003-2007, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
******************************************************************************
|
||||
*
|
||||
* File PERSNCAL.CPP
|
||||
*
|
||||
* Modification History:
|
||||
*
|
||||
* Date Name Description
|
||||
* 9/23/2003 mehran posted to icu-design
|
||||
*****************************************************************************
|
||||
*/
|
||||
#include "persncal.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
static const int monthDays[] = { 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 };
|
||||
|
||||
static int32_t
|
||||
jalali_to_julian(int year, int month, int day)
|
||||
{
|
||||
int32_t daysNo=0;
|
||||
int i;
|
||||
|
||||
year = year -475+2820;
|
||||
month -= 1;
|
||||
|
||||
daysNo=(year/2820)*1029983;
|
||||
year=year % 2820;
|
||||
|
||||
daysNo+=(year/128)* 46751;
|
||||
if((year/128)>21)
|
||||
{
|
||||
daysNo-=46751;
|
||||
year=(year%128)+128;
|
||||
}
|
||||
else
|
||||
year=year%128;
|
||||
|
||||
if(year>=29)
|
||||
{
|
||||
year-=29;
|
||||
daysNo+=10592;
|
||||
}
|
||||
|
||||
if(year>=66)
|
||||
{
|
||||
year-=66;
|
||||
daysNo+=24106;
|
||||
}
|
||||
else if( year>=33)
|
||||
{
|
||||
daysNo+=(year/33)* 12053;
|
||||
year=year%33;
|
||||
}
|
||||
|
||||
if (year >= 5)
|
||||
{
|
||||
daysNo += 1826;
|
||||
year -=5;
|
||||
}
|
||||
else if (year == 4)
|
||||
{
|
||||
daysNo += 1460;
|
||||
year -=4;
|
||||
}
|
||||
|
||||
daysNo += 1461 * (year/4);
|
||||
year %= 4;
|
||||
daysNo += 365 * year;
|
||||
|
||||
for (i = 0; i < month; i++) {
|
||||
daysNo += monthDays[i];
|
||||
}
|
||||
|
||||
daysNo += day;
|
||||
|
||||
return daysNo-856493;
|
||||
}
|
||||
|
||||
static void julian_to_jalali (int32_t daysNo, int *h_y, int *h_m, int *h_d)
|
||||
{
|
||||
int year=0, month=0, day=0,scalarDays=0;
|
||||
int i;
|
||||
|
||||
daysNo+=856493;
|
||||
scalarDays=daysNo;
|
||||
year=(daysNo/1029983)*2820;
|
||||
daysNo=daysNo%1029983;
|
||||
|
||||
if((daysNo/46751)<=21)
|
||||
{
|
||||
year+=(daysNo/46751)* 128;
|
||||
daysNo=daysNo%46751;
|
||||
}
|
||||
else
|
||||
{
|
||||
year+=(daysNo/46751)* 128;
|
||||
daysNo=daysNo%46751;
|
||||
year-=128;
|
||||
daysNo+=46751;
|
||||
}
|
||||
|
||||
if (daysNo >= 10592)
|
||||
{
|
||||
year+= 29;
|
||||
daysNo -= 10592;
|
||||
}
|
||||
|
||||
if(daysNo>=24106)
|
||||
{
|
||||
daysNo-=24106;
|
||||
year+=66;
|
||||
}
|
||||
|
||||
if(daysNo>=12053)
|
||||
{
|
||||
daysNo-=12053;
|
||||
year+=33;
|
||||
}
|
||||
|
||||
|
||||
if (daysNo >= 1826)
|
||||
{
|
||||
year+= 5;
|
||||
daysNo -= 1826;
|
||||
}
|
||||
else if (daysNo > 1095)
|
||||
{
|
||||
year+= 3;
|
||||
daysNo -= 1095;
|
||||
|
||||
}
|
||||
|
||||
year +=(4 * (daysNo/1461));
|
||||
daysNo %= 1461;
|
||||
|
||||
if (daysNo == 0)
|
||||
{
|
||||
year -= 1;
|
||||
daysNo = 366;
|
||||
}
|
||||
else
|
||||
{
|
||||
year += daysNo/365;
|
||||
daysNo = daysNo % 365;
|
||||
if (daysNo == 0)
|
||||
{
|
||||
year -= 1;
|
||||
daysNo = 365;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < 11 && daysNo > monthDays[i]; ++i) {
|
||||
daysNo -= monthDays[i];
|
||||
}
|
||||
|
||||
month = i + 1;
|
||||
|
||||
day = daysNo;
|
||||
|
||||
*h_d = day;
|
||||
*h_m = month;
|
||||
*h_y = year-2345;
|
||||
}
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Implementation of the PersianCalendar class
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Constructors...
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
const char *PersianCalendar::getType() const {
|
||||
return "persian";
|
||||
}
|
||||
|
||||
Calendar* PersianCalendar::clone() const {
|
||||
return new PersianCalendar(*this);
|
||||
}
|
||||
|
||||
PersianCalendar::PersianCalendar(const Locale& aLocale, UErrorCode& success)
|
||||
: Calendar(TimeZone::createDefault(), aLocale, success)
|
||||
{
|
||||
setTimeInMillis(getNow(), success); // Call this again now that the vtable is set up properly.
|
||||
}
|
||||
|
||||
PersianCalendar::PersianCalendar(const PersianCalendar& other) : Calendar(other) {
|
||||
}
|
||||
|
||||
PersianCalendar::~PersianCalendar()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Minimum / Maximum access functions
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
static const int32_t LIMITS[UCAL_FIELD_COUNT][4] = {
|
||||
// Minimum Greatest Least Maximum
|
||||
// Minimum Maximum
|
||||
{ 0, 0, 0, 0 }, // ERA
|
||||
{ -2500, -2500, 2500, 2500 }, // YEAR
|
||||
{ 0, 0, 11, 11 }, // MONTH
|
||||
{ 1, 1, 52, 53 }, // WEEK_OF_YEAR
|
||||
{ 0, 0, 5, 6 }, // WEEK_OF_MONTH
|
||||
{ 1, 1, 29, 31 }, // DAY_OF_MONTH
|
||||
{ 1, 1, 365, 366 }, // DAY_OF_YEAR
|
||||
{ 0, 0, 6, 6 }, // DAY_OF_WEEK
|
||||
{ 1, 1, 4, 6 }, // DAY_OF_WEEK_IN_MONTH
|
||||
{ 0, 0, 1, 1 }, // AM_PM
|
||||
{ 0, 0, 11, 11 }, // HOUR
|
||||
{ 0, 0, 23, 23 }, // HOUR_OF_DAY
|
||||
{ 0, 0, 59, 59 }, // MINUTE
|
||||
{ 0, 0, 59, 59 }, // SECOND
|
||||
{ 0, 0, 999, 999 }, // MILLISECOND
|
||||
{ -12, -12, 12, 12 }, // ZONE_OFFSET
|
||||
{ 0, 0, 1, 1 }, // DST_OFFSET
|
||||
{ -140742, -140742, 144683, 140742 }, // YEAR_WOY
|
||||
{ 0, 0, 6, 6 }, // DOW_LOCAL
|
||||
{ -2500, -2500, 2500, 2500 }, // EXTENDED_YEAR
|
||||
{/* -1, -1, -1, -1 */}, // JULIAN_DAY
|
||||
{/* -1, -1, -1, -1 */}, // MILLISECONDS_IN_DAY
|
||||
};
|
||||
static const int32_t MONTH_COUNT[12][4] = {
|
||||
//len len2 st st2
|
||||
{ 31, 31, 0, 0 }, // Farvardin
|
||||
{ 31, 31, 31, 31 }, // Ordibehesht
|
||||
{ 31, 31, 62, 62 }, // Khordad
|
||||
{ 31, 31, 93, 93 }, // Tir
|
||||
{ 31, 31, 124, 124 }, // Mordad
|
||||
{ 31, 31, 155, 155 }, // Shahrivar
|
||||
{ 30, 30, 186, 186 }, // Mehr
|
||||
{ 30, 30, 216, 216 }, // Aban
|
||||
{ 30, 30, 246, 246 }, // Azar
|
||||
{ 30, 30, 276, 276 }, // Dey
|
||||
{ 30, 30, 306, 306 }, // Bahman
|
||||
{ 29, 30, 336, 336 } // Esfand
|
||||
// len length of month
|
||||
// len2 length of month in a leap year
|
||||
// st days in year before start of month
|
||||
// st2 days in year before month in leap year
|
||||
};
|
||||
|
||||
int32_t PersianCalendar::handleGetLimit(UCalendarDateFields field, ELimitType limitType) const {
|
||||
return LIMITS[field][limitType];
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Assorted calculation utilities
|
||||
//
|
||||
|
||||
/**
|
||||
* Determine whether a year is a leap year in the Persian calendar
|
||||
*/
|
||||
UBool PersianCalendar::isLeapYear(int32_t year)
|
||||
{
|
||||
return jalali_to_julian(year+1,1,1)-jalali_to_julian(year,1,1) == 366;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the day # on which the given year starts. Days are counted
|
||||
* from the Hijri epoch, origin 0.
|
||||
*/
|
||||
int32_t PersianCalendar::yearStart(int32_t year) {
|
||||
return handleComputeMonthStart(year,1,FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the day # on which the given month starts. Days are counted
|
||||
* from the Hijri epoch, origin 0.
|
||||
*
|
||||
* @param year The hijri shamsi year
|
||||
* @param year The hijri shamsi month, 0-based
|
||||
*/
|
||||
int32_t PersianCalendar::monthStart(int32_t year, int32_t month) const {
|
||||
return handleComputeMonthStart(year,month,FALSE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Calendar framework
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the length (in days) of the given month.
|
||||
*
|
||||
* @param year The hijri shamsi year
|
||||
* @param year The hijri shamsi month, 0-based
|
||||
*/
|
||||
int32_t PersianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const {
|
||||
return MONTH_COUNT[month][PersianCalendar::isLeapYear(extendedYear)?1:0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of days in the given Persian year
|
||||
*/
|
||||
int32_t PersianCalendar::handleGetYearLength(int32_t extendedYear) const {
|
||||
return 365 + (PersianCalendar::isLeapYear(extendedYear) ? 1 : 0);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Functions for converting from field values to milliseconds....
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// Return JD of start of given month/year
|
||||
int32_t PersianCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, UBool useMonth) const {
|
||||
// If the month is out of range, adjust it into range, and
|
||||
// modify the extended year value accordingly.
|
||||
if (month < 0 || month > 11) {
|
||||
eyear += month / 12;
|
||||
month = month % 12;
|
||||
}
|
||||
return jalali_to_julian(eyear,(useMonth?month+1:1),1)-1+1947955;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Functions for converting from milliseconds to field values
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
int32_t PersianCalendar::handleGetExtendedYear() {
|
||||
int32_t year;
|
||||
if (newerField(UCAL_EXTENDED_YEAR, UCAL_YEAR) == UCAL_EXTENDED_YEAR) {
|
||||
year = internalGet(UCAL_EXTENDED_YEAR, 1); // Default to year 1
|
||||
} else {
|
||||
year = internalGet(UCAL_YEAR, 1); // Default to year 1
|
||||
}
|
||||
return year;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override Calendar to compute several fields specific to the Persian
|
||||
* calendar system. These are:
|
||||
*
|
||||
* <ul><li>ERA
|
||||
* <li>YEAR
|
||||
* <li>MONTH
|
||||
* <li>DAY_OF_MONTH
|
||||
* <li>DAY_OF_YEAR
|
||||
* <li>EXTENDED_YEAR</ul>
|
||||
*
|
||||
* The DAY_OF_WEEK and DOW_LOCAL fields are already set when this
|
||||
* method is called. The getGregorianXxx() methods return Gregorian
|
||||
* calendar equivalents for the given Julian day.
|
||||
*/
|
||||
void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*status*/) {
|
||||
int jy,jm,jd;
|
||||
julian_to_jalali(julianDay-1947955,&jy,&jm,&jd);
|
||||
internalSet(UCAL_ERA, 0);
|
||||
internalSet(UCAL_YEAR, jy);
|
||||
internalSet(UCAL_EXTENDED_YEAR, jy);
|
||||
internalSet(UCAL_MONTH, jm-1);
|
||||
internalSet(UCAL_DAY_OF_MONTH, jd);
|
||||
internalSet(UCAL_DAY_OF_YEAR, jd + MONTH_COUNT[jm-1][2]);
|
||||
}
|
||||
|
||||
UBool
|
||||
PersianCalendar::inDaylightTime(UErrorCode& status) const
|
||||
{
|
||||
// copied from GregorianCalendar
|
||||
if (U_FAILURE(status) || !getTimeZone().useDaylightTime())
|
||||
return FALSE;
|
||||
|
||||
// Force an update of the state of the Calendar.
|
||||
((PersianCalendar*)this)->complete(status); // cast away const
|
||||
|
||||
return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FALSE);
|
||||
}
|
||||
|
||||
UBool PersianCalendar::haveDefaultCentury() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UDate PersianCalendar::defaultCenturyStart() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t PersianCalendar::defaultCenturyStartYear() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(PersianCalendar)
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1038,6 +1038,9 @@ SimpleTimeZone::initTransitionRules(UErrorCode& status) {
|
|||
case DOW_LE_DOM_MODE:
|
||||
dtRule = new DateTimeRule(startMonth, startDay, startDayOfWeek, false, startTime, timeRuleType);
|
||||
break;
|
||||
default:
|
||||
status = U_INVALID_STATE_ERROR;
|
||||
return;
|
||||
}
|
||||
// For now, use ID + "(DST)" as the name
|
||||
dstRule = new AnnualTimeZoneRule(tzid+"(DST)", getRawOffset(), getDSTSavings(),
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,142 +1,142 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/tzrule.h"
|
||||
#include "unicode/tztrans.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const UDate& time, const TimeZoneRule& from, const TimeZoneRule& to)
|
||||
: UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const UDate& time, TimeZoneRule* from, TimeZoneRule* to)
|
||||
: UObject(), fTime(time), fFrom(from), fTo(to) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition()
|
||||
: UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
|
||||
: UObject(), fTime(source.fTime), fFrom(source.fFrom->clone()),
|
||||
fTo(source.fTo->clone()) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::~TimeZoneTransition() {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
}
|
||||
|
||||
TimeZoneTransition*
|
||||
TimeZoneTransition::clone(void) const {
|
||||
return new TimeZoneTransition(*this);
|
||||
}
|
||||
|
||||
TimeZoneTransition&
|
||||
TimeZoneTransition::operator=(const TimeZoneTransition& right) {
|
||||
if (this != &right) {
|
||||
fTime = right.fTime;
|
||||
setFrom(*right.fFrom);
|
||||
setTo(*right.fTo);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
UBool
|
||||
TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
|
||||
if (this == &that) {
|
||||
return TRUE;
|
||||
}
|
||||
if (getDynamicClassID() != that.getDynamicClassID()) {
|
||||
return FALSE;
|
||||
}
|
||||
if (fTime != that.fTime) {
|
||||
return FALSE;
|
||||
}
|
||||
if (fFrom == NULL && that.fFrom == NULL
|
||||
|| fFrom != NULL && that.fFrom != NULL && fFrom == that.fFrom) {
|
||||
if (fTo == NULL && that.fTo == NULL
|
||||
|| fTo != NULL && that.fTo != NULL && fTo == that.fTo) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UBool
|
||||
TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setTime(UDate time) {
|
||||
fTime = time;
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setFrom(const TimeZoneRule& from) {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
fFrom = from.clone();
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
fFrom = from;
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setTo(const TimeZoneRule& to) {
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
fTo = to.clone();
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::adoptTo(TimeZoneRule* to) {
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
fTo = to;
|
||||
}
|
||||
|
||||
UDate
|
||||
TimeZoneTransition::getTime(void) const {
|
||||
return fTime;
|
||||
}
|
||||
|
||||
const TimeZoneRule*
|
||||
TimeZoneTransition::getTo(void) const {
|
||||
return fTo;
|
||||
}
|
||||
|
||||
const TimeZoneRule*
|
||||
TimeZoneTransition::getFrom(void) const {
|
||||
return fFrom;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/tzrule.h"
|
||||
#include "unicode/tztrans.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeZoneTransition)
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const UDate& time, const TimeZoneRule& from, const TimeZoneRule& to)
|
||||
: UObject(), fTime(time), fFrom(from.clone()), fTo(to.clone()) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const UDate& time, TimeZoneRule* from, TimeZoneRule* to)
|
||||
: UObject(), fTime(time), fFrom(from), fTo(to) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition()
|
||||
: UObject(), fTime(0), fFrom(NULL), fTo(NULL) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::TimeZoneTransition(const TimeZoneTransition& source)
|
||||
: UObject(), fTime(source.fTime), fFrom(source.fFrom->clone()),
|
||||
fTo(source.fTo->clone()) {
|
||||
}
|
||||
|
||||
TimeZoneTransition::~TimeZoneTransition() {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
}
|
||||
|
||||
TimeZoneTransition*
|
||||
TimeZoneTransition::clone(void) const {
|
||||
return new TimeZoneTransition(*this);
|
||||
}
|
||||
|
||||
TimeZoneTransition&
|
||||
TimeZoneTransition::operator=(const TimeZoneTransition& right) {
|
||||
if (this != &right) {
|
||||
fTime = right.fTime;
|
||||
setFrom(*right.fFrom);
|
||||
setTo(*right.fTo);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
UBool
|
||||
TimeZoneTransition::operator==(const TimeZoneTransition& that) const {
|
||||
if (this == &that) {
|
||||
return TRUE;
|
||||
}
|
||||
if (getDynamicClassID() != that.getDynamicClassID()) {
|
||||
return FALSE;
|
||||
}
|
||||
if (fTime != that.fTime) {
|
||||
return FALSE;
|
||||
}
|
||||
if (fFrom == NULL && that.fFrom == NULL
|
||||
|| fFrom != NULL && that.fFrom != NULL && fFrom == that.fFrom) {
|
||||
if (fTo == NULL && that.fTo == NULL
|
||||
|| fTo != NULL && that.fTo != NULL && fTo == that.fTo) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UBool
|
||||
TimeZoneTransition::operator!=(const TimeZoneTransition& that) const {
|
||||
return !operator==(that);
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setTime(UDate time) {
|
||||
fTime = time;
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setFrom(const TimeZoneRule& from) {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
fFrom = from.clone();
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::adoptFrom(TimeZoneRule* from) {
|
||||
if (fFrom != NULL) {
|
||||
delete fFrom;
|
||||
}
|
||||
fFrom = from;
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::setTo(const TimeZoneRule& to) {
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
fTo = to.clone();
|
||||
}
|
||||
|
||||
void
|
||||
TimeZoneTransition::adoptTo(TimeZoneRule* to) {
|
||||
if (fTo != NULL) {
|
||||
delete fTo;
|
||||
}
|
||||
fTo = to;
|
||||
}
|
||||
|
||||
UDate
|
||||
TimeZoneTransition::getTime(void) const {
|
||||
return fTime;
|
||||
}
|
||||
|
||||
const TimeZoneRule*
|
||||
TimeZoneTransition::getTo(void) const {
|
||||
return fTo;
|
||||
}
|
||||
|
||||
const TimeZoneRule*
|
||||
TimeZoneTransition::getFrom(void) const {
|
||||
return fFrom;
|
||||
}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
|
||||
//eof
|
||||
|
|
|
@ -1,181 +1,181 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef BASICTZ_H
|
||||
#define BASICTZ_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: ICU TimeZone base class
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/timezone.h"
|
||||
#include "unicode/tzrule.h"
|
||||
#include "unicode/tztrans.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// forward declarations
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
|
||||
* This class provides some additional methods to access time zone transitions and rules.
|
||||
* All ICU <code>TimeZone</code> concrete subclasses extend this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API BasicTimeZone: public TimeZone {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~BasicTimeZone();
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Checks if the time zone has equivalent transitions in the time range.
|
||||
* This method returns true when all of transition times, from/to standard
|
||||
* offsets and DST savings used by this time zone match the other in the
|
||||
* time range.
|
||||
* @param tz The <code>BasicTimeZone</code> object to be compared with.
|
||||
* @param start The start time of the evaluated time range (inclusive)
|
||||
* @param end The end time of the evaluated time range (inclusive)
|
||||
* @param ignoreDstAmount
|
||||
* When true, any transitions with only daylight saving amount
|
||||
* changes will be ignored, except either of them is zero.
|
||||
* For example, a transition from rawoffset 3:00/dstsavings 1:00
|
||||
* to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
|
||||
* but a transtion from rawoffset 2:00/dstsavings 1:00 to
|
||||
* rawoffset 3:00/dstsavings 0:00 is included.
|
||||
* @param ec Output param to filled in with a success or an error.
|
||||
* @return true if the other time zone has the equivalent transitions in the
|
||||
* time range.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end,
|
||||
UBool ignoreDstAmount, UErrorCode& ec) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the set of time zone rules valid at the specified time. Some known external time zone
|
||||
* implementations are not capable to handle historic time zone rule changes. Also some
|
||||
* implementations can only handle certain type of rule definitions.
|
||||
* If this time zone does not use any daylight saving time within about 1 year from the specified
|
||||
* time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard
|
||||
* time and daylight saving time transitions are returned in addition to the
|
||||
* <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are
|
||||
* represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
|
||||
* rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time
|
||||
* rule is changing time to time in many time zones and also mapping a transition time rule to
|
||||
* different type is lossy transformation, the set of rules returned by this method may be valid
|
||||
* for short period of time.
|
||||
* The time zone rule objects returned by this method is owned by the caller, so the caller is
|
||||
* responsible for deleting them after use.
|
||||
* @param date The date used for extracting time zone rules.
|
||||
* @param initial Receives the <code>InitialTimeZone</code>, always not NULL.
|
||||
* @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
|
||||
* When this time time zone does not observe daylight saving times around the
|
||||
* specified date, NULL is set.
|
||||
* @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
|
||||
* transitions. When this time zone does not observer daylight saving times
|
||||
* around the specified date, NULL is set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
|
||||
AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Default constructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone();
|
||||
|
||||
/*
|
||||
* Construct a timezone with a given ID.
|
||||
* @param id a system time zone ID
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const UnicodeString &id);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source the object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const BasicTimeZone& source);
|
||||
|
||||
/**
|
||||
* Gets the set of TimeZoneRule instances applicable to the specified time and after.
|
||||
* @param start The start date used for extracting time zone rules
|
||||
* @param initial Receives the InitialTimeZone, always not NULL
|
||||
* @param transitionRules Receives the transition rules, could be NULL
|
||||
* @param status Receives error status code
|
||||
*/
|
||||
void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
|
||||
UErrorCode& status) /*const*/;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // BASICTZ_H
|
||||
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef BASICTZ_H
|
||||
#define BASICTZ_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: ICU TimeZone base class
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/timezone.h"
|
||||
#include "unicode/tzrule.h"
|
||||
#include "unicode/tztrans.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// forward declarations
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>.
|
||||
* This class provides some additional methods to access time zone transitions and rules.
|
||||
* All ICU <code>TimeZone</code> concrete subclasses extend this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API BasicTimeZone: public TimeZone {
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~BasicTimeZone();
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Checks if the time zone has equivalent transitions in the time range.
|
||||
* This method returns true when all of transition times, from/to standard
|
||||
* offsets and DST savings used by this time zone match the other in the
|
||||
* time range.
|
||||
* @param tz The <code>BasicTimeZone</code> object to be compared with.
|
||||
* @param start The start time of the evaluated time range (inclusive)
|
||||
* @param end The end time of the evaluated time range (inclusive)
|
||||
* @param ignoreDstAmount
|
||||
* When true, any transitions with only daylight saving amount
|
||||
* changes will be ignored, except either of them is zero.
|
||||
* For example, a transition from rawoffset 3:00/dstsavings 1:00
|
||||
* to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison,
|
||||
* but a transtion from rawoffset 2:00/dstsavings 1:00 to
|
||||
* rawoffset 3:00/dstsavings 0:00 is included.
|
||||
* @param ec Output param to filled in with a success or an error.
|
||||
* @return true if the other time zone has the equivalent transitions in the
|
||||
* time range.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool hasEquivalentTransitions(/*const*/ BasicTimeZone& tz, UDate start, UDate end,
|
||||
UBool ignoreDstAmount, UErrorCode& ec) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/ = 0;
|
||||
|
||||
/**
|
||||
* Gets the set of time zone rules valid at the specified time. Some known external time zone
|
||||
* implementations are not capable to handle historic time zone rule changes. Also some
|
||||
* implementations can only handle certain type of rule definitions.
|
||||
* If this time zone does not use any daylight saving time within about 1 year from the specified
|
||||
* time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard
|
||||
* time and daylight saving time transitions are returned in addition to the
|
||||
* <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are
|
||||
* represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date
|
||||
* rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time
|
||||
* rule is changing time to time in many time zones and also mapping a transition time rule to
|
||||
* different type is lossy transformation, the set of rules returned by this method may be valid
|
||||
* for short period of time.
|
||||
* The time zone rule objects returned by this method is owned by the caller, so the caller is
|
||||
* responsible for deleting them after use.
|
||||
* @param date The date used for extracting time zone rules.
|
||||
* @param initial Receives the <code>InitialTimeZone</code>, always not NULL.
|
||||
* @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions.
|
||||
* When this time time zone does not observe daylight saving times around the
|
||||
* specified date, NULL is set.
|
||||
* @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time
|
||||
* transitions. When this time zone does not observer daylight saving times
|
||||
* around the specified date, NULL is set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial,
|
||||
AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) /*const*/;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Default constructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone();
|
||||
|
||||
/*
|
||||
* Construct a timezone with a given ID.
|
||||
* @param id a system time zone ID
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const UnicodeString &id);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source the object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
BasicTimeZone(const BasicTimeZone& source);
|
||||
|
||||
/**
|
||||
* Gets the set of TimeZoneRule instances applicable to the specified time and after.
|
||||
* @param start The start date used for extracting time zone rules
|
||||
* @param initial Receives the InitialTimeZone, always not NULL
|
||||
* @param transitionRules Receives the transition rules, could be NULL
|
||||
* @param status Receives error status code
|
||||
*/
|
||||
void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules,
|
||||
UErrorCode& status) /*const*/;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // BASICTZ_H
|
||||
|
||||
//eof
|
||||
|
|
|
@ -1,250 +1,250 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef DTRULE_H
|
||||
#define DTRULE_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Rule for specifying date and time in an year
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
/**
|
||||
* <code>DateTimeRule</code> is a class representing a time in a year by
|
||||
* a rule specified by month, day of month, day of week and
|
||||
* time in the day.
|
||||
*
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API DateTimeRule : public UObject {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Date rule type constants.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
enum DateRuleType {
|
||||
DOM = 0, /**< The exact day of month,
|
||||
for example, March 11. */
|
||||
DOW, /**< The Nth occurence of the day of week,
|
||||
for example, 2nd Sunday in March. */
|
||||
DOW_GEQ_DOM, /**< The first occurence of the day of week on or after the day of monnth,
|
||||
for example, first Sunday on or after March 8. */
|
||||
DOW_LEQ_DOM /**< The last occurence of the day of week on or before the day of month,
|
||||
for example, first Sunday on or before March 14. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Time rule type constants.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
enum TimeRuleType {
|
||||
WALL_TIME = 0, /**< The local wall clock time */
|
||||
STANDARD_TIME, /**< The local standard time */
|
||||
UTC_TIME /**< The UTC time */
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the day of month and
|
||||
* the time rule. The date rule type for an instance created by
|
||||
* this constructor is <code>DOM</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>
|
||||
* @param dayOfMonth The day of month, 1-based.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t dayOfMonth,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the day of week and its oridinal
|
||||
* number and the time rule. The date rule type for an instance created
|
||||
* by this constructor is <code>DOW</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>.
|
||||
* @param weekInMonth The ordinal number of the day of week. Negative number
|
||||
* may be used for specifying a rule date counted from the
|
||||
* end of the rule month.
|
||||
* @param dayOfWeek The day of week, for example, <code>Calendar::SUNDAY</code>.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the first/last day of week
|
||||
* on or after/before the day of month and the time rule. The date rule
|
||||
* type for an instance created by this constructor is either
|
||||
* <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>
|
||||
* @param dayOfMonth The day of month, 1-based.
|
||||
* @param dayOfWeek The day of week, for example, <code>Calendar::SUNDAY</code>.
|
||||
* @param after true if the rule date is on or after the day of month.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The DateTimeRule object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(const DateTimeRule& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
~DateTimeRule();
|
||||
|
||||
/**
|
||||
* Clone this DateTimeRule object polymorphically. The caller owns the result and
|
||||
* should delete it when done.
|
||||
* @return A copy of the object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule* clone(void) const;
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule& operator=(const DateTimeRule& right);
|
||||
|
||||
/**
|
||||
* Return true if the given DateTimeRule objects are semantically equal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given DateTimeRule objects are semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator==(const DateTimeRule& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given DateTimeRule objects are semantically unequal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given DateTimeRule objects are semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator!=(const DateTimeRule& that) const;
|
||||
|
||||
/**
|
||||
* Gets the date rule type, such as <code>DOM</code>
|
||||
* @return The date rule type.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateRuleType getDateRuleType(void) const;
|
||||
|
||||
/**
|
||||
* Gets the time rule type
|
||||
* @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeRuleType getTimeRuleType(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule month.
|
||||
* @return The rule month.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule day of month. When the date rule type
|
||||
* is <code>DOW</code>, the value is always 0.
|
||||
* @return The rule day of month
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleDayOfMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule day of week. When the date rule type
|
||||
* is <code>DOM</code>, the value is always 0.
|
||||
* @return The rule day of week.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleDayOfWeek(void) const;
|
||||
|
||||
/**
|
||||
* Gets the ordinal number of the occurence of the day of week
|
||||
* in the month. When the date rule type is not <code>DOW</code>,
|
||||
* the value is always 0.
|
||||
* @return The rule day of week ordinal number in the month.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleWeekInMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule time in the rule day.
|
||||
* @return The time in the rule day in milliseconds.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleMillisInDay(void) const;
|
||||
|
||||
private:
|
||||
DateRuleType fDateRuleType;
|
||||
TimeRuleType fTimeRuleType;
|
||||
int32_t fMonth;
|
||||
int32_t fDayOfMonth;
|
||||
int32_t fDayOfWeek;
|
||||
int32_t fWeekInMonth;
|
||||
int32_t fMillisInDay;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // DTRULE_H
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef DTRULE_H
|
||||
#define DTRULE_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Rule for specifying date and time in an year
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
/**
|
||||
* <code>DateTimeRule</code> is a class representing a time in a year by
|
||||
* a rule specified by month, day of month, day of week and
|
||||
* time in the day.
|
||||
*
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API DateTimeRule : public UObject {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Date rule type constants.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
enum DateRuleType {
|
||||
DOM = 0, /**< The exact day of month,
|
||||
for example, March 11. */
|
||||
DOW, /**< The Nth occurence of the day of week,
|
||||
for example, 2nd Sunday in March. */
|
||||
DOW_GEQ_DOM, /**< The first occurence of the day of week on or after the day of monnth,
|
||||
for example, first Sunday on or after March 8. */
|
||||
DOW_LEQ_DOM /**< The last occurence of the day of week on or before the day of month,
|
||||
for example, first Sunday on or before March 14. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Time rule type constants.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
enum TimeRuleType {
|
||||
WALL_TIME = 0, /**< The local wall clock time */
|
||||
STANDARD_TIME, /**< The local standard time */
|
||||
UTC_TIME /**< The UTC time */
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the day of month and
|
||||
* the time rule. The date rule type for an instance created by
|
||||
* this constructor is <code>DOM</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>
|
||||
* @param dayOfMonth The day of month, 1-based.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t dayOfMonth,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the day of week and its oridinal
|
||||
* number and the time rule. The date rule type for an instance created
|
||||
* by this constructor is <code>DOW</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>.
|
||||
* @param weekInMonth The ordinal number of the day of week. Negative number
|
||||
* may be used for specifying a rule date counted from the
|
||||
* end of the rule month.
|
||||
* @param dayOfWeek The day of week, for example, <code>Calendar::SUNDAY</code>.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Constructs a <code>DateTimeRule</code> by the first/last day of week
|
||||
* on or after/before the day of month and the time rule. The date rule
|
||||
* type for an instance created by this constructor is either
|
||||
* <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
|
||||
*
|
||||
* @param month The rule month, for example, <code>Calendar::JANUARY</code>
|
||||
* @param dayOfMonth The day of month, 1-based.
|
||||
* @param dayOfWeek The day of week, for example, <code>Calendar::SUNDAY</code>.
|
||||
* @param after true if the rule date is on or after the day of month.
|
||||
* @param millisInDay The milliseconds in the rule date.
|
||||
* @param timeType The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
|
||||
int32_t millisInDay, TimeRuleType timeType);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The DateTimeRule object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule(const DateTimeRule& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
~DateTimeRule();
|
||||
|
||||
/**
|
||||
* Clone this DateTimeRule object polymorphically. The caller owns the result and
|
||||
* should delete it when done.
|
||||
* @return A copy of the object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule* clone(void) const;
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateTimeRule& operator=(const DateTimeRule& right);
|
||||
|
||||
/**
|
||||
* Return true if the given DateTimeRule objects are semantically equal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given DateTimeRule objects are semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator==(const DateTimeRule& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given DateTimeRule objects are semantically unequal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given DateTimeRule objects are semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator!=(const DateTimeRule& that) const;
|
||||
|
||||
/**
|
||||
* Gets the date rule type, such as <code>DOM</code>
|
||||
* @return The date rule type.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
DateRuleType getDateRuleType(void) const;
|
||||
|
||||
/**
|
||||
* Gets the time rule type
|
||||
* @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
|
||||
* or <code>UTC_TIME</code>.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeRuleType getTimeRuleType(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule month.
|
||||
* @return The rule month.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule day of month. When the date rule type
|
||||
* is <code>DOW</code>, the value is always 0.
|
||||
* @return The rule day of month
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleDayOfMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule day of week. When the date rule type
|
||||
* is <code>DOM</code>, the value is always 0.
|
||||
* @return The rule day of week.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleDayOfWeek(void) const;
|
||||
|
||||
/**
|
||||
* Gets the ordinal number of the occurence of the day of week
|
||||
* in the month. When the date rule type is not <code>DOW</code>,
|
||||
* the value is always 0.
|
||||
* @return The rule day of week ordinal number in the month.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleWeekInMonth(void) const;
|
||||
|
||||
/**
|
||||
* Gets the rule time in the rule day.
|
||||
* @return The time in the rule day in milliseconds.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
int32_t getRuleMillisInDay(void) const;
|
||||
|
||||
private:
|
||||
int32_t fMonth;
|
||||
int32_t fDayOfMonth;
|
||||
int32_t fDayOfWeek;
|
||||
int32_t fWeekInMonth;
|
||||
int32_t fMillisInDay;
|
||||
DateRuleType fDateRuleType;
|
||||
TimeRuleType fTimeRuleType;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // DTRULE_H
|
||||
//eof
|
||||
|
|
|
@ -1,340 +1,340 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef RBTZ_H
|
||||
#define RBTZ_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Rule based customizable time zone
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/basictz.h"
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// forward declaration
|
||||
class UVector;
|
||||
|
||||
class U_I18N_API RuleBasedTimeZone : public BasicTimeZone {
|
||||
public:
|
||||
/**
|
||||
* Constructs a <code>RuleBasedTimeZone</code> object with the ID and the
|
||||
* <code>InitialTimeZoneRule</code>. The input <code>InitialTimeZoneRule</code>
|
||||
* is adopted by this <code>RuleBasedTimeZone</code>, thus the caller must not
|
||||
* delete it.
|
||||
* @param id The time zone ID.
|
||||
* @param initialRule The initial time zone rule.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The RuleBasedTimeZone object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone(const RuleBasedTimeZone& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~RuleBasedTimeZone();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone& operator=(const RuleBasedTimeZone& right);
|
||||
|
||||
/**
|
||||
* Return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically equal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
*semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator==(const RuleBasedTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically unequal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator!=(const RuleBasedTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Adds the <code>TimeZoneRule</code> which represents time transitions.
|
||||
* The <code>TimeZoneRule</code> must have start times, that is, the result
|
||||
* of isTransitionRule() must be true. Otherwise, U_ILLEGAL_ARGUMENT_ERROR
|
||||
* is set to the error code.
|
||||
* The input <code>TimeZoneRule</code> is adopted by this
|
||||
* <code>RuleBasedTimeZone</code> on successful completion of this method,
|
||||
* thus, the caller must not delete it when no error is returned.
|
||||
* After all rules are added, the caller must call complete() method to
|
||||
* make this <code>RuleBasedTimeZone</code> ready to handle common time
|
||||
* zone functions.
|
||||
* @param rule The <code>TimeZoneRule</code>.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void addTransitionRule(TimeZoneRule* rule, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Makes the <code>TimeZoneRule</code> ready to handle actual timezone
|
||||
* calcuation APIs. This method collects time zone rules specified
|
||||
* by the caller via the constructor and addTransitionRule() and
|
||||
* builds internal structure for making the object ready to support
|
||||
* time zone APIs such as getOffset(), getNextTransition() and others.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void complete(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Clones TimeZone objects polymorphically. Clients are responsible for deleting
|
||||
* the TimeZone object cloned.
|
||||
*
|
||||
* @return A new copy of this TimeZone object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual TimeZone* clone(void) const;
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time in this time zone, taking daylight savings time into
|
||||
* account) as of a particular reference date. The reference date is used to determine
|
||||
* whether daylight savings time is in effect and needs to be figured into the offset
|
||||
* that is returned (in other words, what is the adjusted GMT offset in this time zone
|
||||
* at this particular date and time?). For the time zones produced by createTimeZone(),
|
||||
* the reference data is specified according to the Gregorian calendar, and the date
|
||||
* and time fields are local standard time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Gets the time zone offset, for current date, modified in case of
|
||||
* daylight savings. This is the offset to add *to* UTC to get local time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param monthLength The length of the given month in days.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
|
||||
uint8_t dayOfWeek, int32_t millis,
|
||||
int32_t monthLength, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns the time zone raw and GMT offset for the given moment
|
||||
* in time. Upon return, local-millis = GMT-millis + rawOffset +
|
||||
* dstOffset. All computations are performed in the proleptic
|
||||
* Gregorian calendar. The default implementation in the TimeZone
|
||||
* class delegates to the 8-argument getOffset().
|
||||
*
|
||||
* @param date moment in time for which to return offsets, in
|
||||
* units of milliseconds from January 1, 1970 0:00 GMT, either GMT
|
||||
* time or local wall time, depending on `local'.
|
||||
* @param local if true, `date' is local wall time; otherwise it
|
||||
* is in GMT time.
|
||||
* @param rawOffset output parameter to receive the raw offset, that
|
||||
* is, the offset not including DST adjustments
|
||||
* @param dstOffset output parameter to receive the DST offset,
|
||||
* that is, the offset to be added to `rawOffset' to obtain the
|
||||
* total offset between local and GMT time. If DST is not in
|
||||
* effect, this value is zero; otherwise it is a positive value,
|
||||
* typically one hour.
|
||||
* @param ec input-output error code
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
|
||||
int32_t& dstOffset, UErrorCode& ec) const;
|
||||
|
||||
/**
|
||||
* Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @param offsetMillis The new raw GMT offset for this time zone.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void setRawOffset(int32_t offsetMillis);
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @return The TimeZone's raw GMT offset.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getRawOffset(void) const;
|
||||
|
||||
/**
|
||||
* Queries if this time zone uses daylight savings time.
|
||||
* @return true if this time zone uses daylight savings time,
|
||||
* false, otherwise.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool useDaylightTime(void) const;
|
||||
|
||||
/**
|
||||
* Queries if the given date is in daylight savings time in
|
||||
* this time zone.
|
||||
* This method is wasteful since it creates a new GregorianCalendar and
|
||||
* deletes it each time it is called. This is a deprecated method
|
||||
* and provided only for Java compatibility.
|
||||
*
|
||||
* @param date the given UDate.
|
||||
* @param status Output param filled in with success/error code.
|
||||
* @return true if the given date is in daylight savings time,
|
||||
* false, otherwise.
|
||||
* @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
|
||||
*/
|
||||
virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns true if this zone has the same rule and offset as another zone.
|
||||
* That is, if this zone differs only in ID, if at all.
|
||||
* @param other the <code>TimeZone</code> object to be compared with
|
||||
* @return true if the given zone is the same as this one,
|
||||
* with the possible exception of the ID
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool hasSameRules(const TimeZone& other) const;
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
|
||||
|
||||
private:
|
||||
void deleteRules(void);
|
||||
void deleteTransitions(void);
|
||||
UVector* copyRules(UVector* source);
|
||||
TimeZoneRule* findRuleInFinal(UDate date, UBool local) const;
|
||||
UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
|
||||
UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
|
||||
|
||||
UBool fUpToDate;
|
||||
InitialTimeZoneRule *fInitialRule;
|
||||
UVector *fHistoricRules;
|
||||
UVector *fFinalRules;
|
||||
UVector *fHistoricTransitions;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // RBTZ_H
|
||||
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef RBTZ_H
|
||||
#define RBTZ_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Rule based customizable time zone
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/basictz.h"
|
||||
#include "unicode/unistr.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// forward declaration
|
||||
class UVector;
|
||||
|
||||
class U_I18N_API RuleBasedTimeZone : public BasicTimeZone {
|
||||
public:
|
||||
/**
|
||||
* Constructs a <code>RuleBasedTimeZone</code> object with the ID and the
|
||||
* <code>InitialTimeZoneRule</code>. The input <code>InitialTimeZoneRule</code>
|
||||
* is adopted by this <code>RuleBasedTimeZone</code>, thus the caller must not
|
||||
* delete it.
|
||||
* @param id The time zone ID.
|
||||
* @param initialRule The initial time zone rule.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone(const UnicodeString& id, InitialTimeZoneRule* initialRule);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The RuleBasedTimeZone object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone(const RuleBasedTimeZone& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~RuleBasedTimeZone();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
RuleBasedTimeZone& operator=(const RuleBasedTimeZone& right);
|
||||
|
||||
/**
|
||||
* Return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically equal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
*semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator==(const RuleBasedTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically unequal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>RuleBasedTimeZone</code> objects are
|
||||
* semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator!=(const RuleBasedTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Adds the <code>TimeZoneRule</code> which represents time transitions.
|
||||
* The <code>TimeZoneRule</code> must have start times, that is, the result
|
||||
* of isTransitionRule() must be true. Otherwise, U_ILLEGAL_ARGUMENT_ERROR
|
||||
* is set to the error code.
|
||||
* The input <code>TimeZoneRule</code> is adopted by this
|
||||
* <code>RuleBasedTimeZone</code> on successful completion of this method,
|
||||
* thus, the caller must not delete it when no error is returned.
|
||||
* After all rules are added, the caller must call complete() method to
|
||||
* make this <code>RuleBasedTimeZone</code> ready to handle common time
|
||||
* zone functions.
|
||||
* @param rule The <code>TimeZoneRule</code>.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void addTransitionRule(TimeZoneRule* rule, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Makes the <code>TimeZoneRule</code> ready to handle actual timezone
|
||||
* calcuation APIs. This method collects time zone rules specified
|
||||
* by the caller via the constructor and addTransitionRule() and
|
||||
* builds internal structure for making the object ready to support
|
||||
* time zone APIs such as getOffset(), getNextTransition() and others.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void complete(UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Clones TimeZone objects polymorphically. Clients are responsible for deleting
|
||||
* the TimeZone object cloned.
|
||||
*
|
||||
* @return A new copy of this TimeZone object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual TimeZone* clone(void) const;
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time in this time zone, taking daylight savings time into
|
||||
* account) as of a particular reference date. The reference date is used to determine
|
||||
* whether daylight savings time is in effect and needs to be figured into the offset
|
||||
* that is returned (in other words, what is the adjusted GMT offset in this time zone
|
||||
* at this particular date and time?). For the time zones produced by createTimeZone(),
|
||||
* the reference data is specified according to the Gregorian calendar, and the date
|
||||
* and time fields are local standard time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Gets the time zone offset, for current date, modified in case of
|
||||
* daylight savings. This is the offset to add *to* UTC to get local time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param monthLength The length of the given month in days.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
|
||||
uint8_t dayOfWeek, int32_t millis,
|
||||
int32_t monthLength, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns the time zone raw and GMT offset for the given moment
|
||||
* in time. Upon return, local-millis = GMT-millis + rawOffset +
|
||||
* dstOffset. All computations are performed in the proleptic
|
||||
* Gregorian calendar. The default implementation in the TimeZone
|
||||
* class delegates to the 8-argument getOffset().
|
||||
*
|
||||
* @param date moment in time for which to return offsets, in
|
||||
* units of milliseconds from January 1, 1970 0:00 GMT, either GMT
|
||||
* time or local wall time, depending on `local'.
|
||||
* @param local if true, `date' is local wall time; otherwise it
|
||||
* is in GMT time.
|
||||
* @param rawOffset output parameter to receive the raw offset, that
|
||||
* is, the offset not including DST adjustments
|
||||
* @param dstOffset output parameter to receive the DST offset,
|
||||
* that is, the offset to be added to `rawOffset' to obtain the
|
||||
* total offset between local and GMT time. If DST is not in
|
||||
* effect, this value is zero; otherwise it is a positive value,
|
||||
* typically one hour.
|
||||
* @param ec input-output error code
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
|
||||
int32_t& dstOffset, UErrorCode& ec) const;
|
||||
|
||||
/**
|
||||
* Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @param offsetMillis The new raw GMT offset for this time zone.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void setRawOffset(int32_t offsetMillis);
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @return The TimeZone's raw GMT offset.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getRawOffset(void) const;
|
||||
|
||||
/**
|
||||
* Queries if this time zone uses daylight savings time.
|
||||
* @return true if this time zone uses daylight savings time,
|
||||
* false, otherwise.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool useDaylightTime(void) const;
|
||||
|
||||
/**
|
||||
* Queries if the given date is in daylight savings time in
|
||||
* this time zone.
|
||||
* This method is wasteful since it creates a new GregorianCalendar and
|
||||
* deletes it each time it is called. This is a deprecated method
|
||||
* and provided only for Java compatibility.
|
||||
*
|
||||
* @param date the given UDate.
|
||||
* @param status Output param filled in with success/error code.
|
||||
* @return true if the given date is in daylight savings time,
|
||||
* false, otherwise.
|
||||
* @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
|
||||
*/
|
||||
virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns true if this zone has the same rule and offset as another zone.
|
||||
* That is, if this zone differs only in ID, if at all.
|
||||
* @param other the <code>TimeZone</code> object to be compared with
|
||||
* @return true if the given zone is the same as this one,
|
||||
* with the possible exception of the ID
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool hasSameRules(const TimeZone& other) const;
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
|
||||
|
||||
private:
|
||||
void deleteRules(void);
|
||||
void deleteTransitions(void);
|
||||
UVector* copyRules(UVector* source);
|
||||
TimeZoneRule* findRuleInFinal(UDate date, UBool local) const;
|
||||
UBool findNext(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
|
||||
UBool findPrev(UDate base, UBool inclusive, UDate& time, TimeZoneRule*& from, TimeZoneRule*& to) const;
|
||||
|
||||
InitialTimeZoneRule *fInitialRule;
|
||||
UVector *fHistoricRules;
|
||||
UVector *fFinalRules;
|
||||
UVector *fHistoricTransitions;
|
||||
UBool fUpToDate;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // RBTZ_H
|
||||
|
||||
//eof
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,190 +1,190 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef TZTRANS_H
|
||||
#define TZTRANS_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Time zone transition
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Forward declaration
|
||||
class TimeZoneRule;
|
||||
|
||||
/**
|
||||
* <code>TimeZoneTransition</code> is a class representing a time zone transition.
|
||||
* An instance has a time of transition and rules for both before and after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API TimeZoneTransition : public UObject {
|
||||
public:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
TimeZoneTransition(const UDate& time, const TimeZoneRule& from, const TimeZoneRule& to);
|
||||
TimeZoneTransition(const UDate& time, TimeZoneRule* from, TimeZoneRule* to);
|
||||
|
||||
/**
|
||||
* Constructs an empty <code>TimeZoneTransition</code>
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition();
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The TimeZoneTransition object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition(const TimeZoneTransition& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
~TimeZoneTransition();
|
||||
|
||||
/**
|
||||
* Clone this TimeZoneTransition object polymorphically. The caller owns the result and
|
||||
* should delete it when done.
|
||||
* @return A copy of the object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition* clone(void) const;
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition& operator=(const TimeZoneTransition& right);
|
||||
|
||||
/**
|
||||
* Return true if the given TimeZoneTransition objects are semantically equal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given TimeZoneTransition objects are semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator==(const TimeZoneTransition& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given TimeZoneTransition objects are semantically unequal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given TimeZoneTransition objects are semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator!=(const TimeZoneTransition& that) const;
|
||||
|
||||
/**
|
||||
* Returns the time of transition in milliseconds.
|
||||
* @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UDate getTime(void) const;
|
||||
|
||||
/**
|
||||
* Sets the time of transition in milliseconds.
|
||||
* @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTime(UDate time);
|
||||
|
||||
/**
|
||||
* Returns the rule used before the transition.
|
||||
* @return The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
const TimeZoneRule* getFrom(void) const;
|
||||
|
||||
/**
|
||||
* Sets the rule used before the transition. The caller remains
|
||||
* responsible for deleting the <code>TimeZoneRule</code> object.
|
||||
* @param from The time zone rule used before the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setFrom(const TimeZoneRule& from);
|
||||
|
||||
/**
|
||||
* Adopts the rule used before the transition. The caller must
|
||||
* not delete the <code>TimeZoneRule</code> object passed in.
|
||||
* @param from The time zone rule used before the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void adoptFrom(TimeZoneRule* from);
|
||||
|
||||
/**
|
||||
* Sets the rule used after the transition. The caller remains
|
||||
* responsible for deleting the <code>TimeZoneRule</code> object.
|
||||
* @param to The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTo(const TimeZoneRule& to);
|
||||
|
||||
/**
|
||||
* Adopts the rule used after the transition. The caller must
|
||||
* not delete the <code>TimeZoneRule</code> object passed in.
|
||||
* @param to The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void adoptTo(TimeZoneRule* to);
|
||||
|
||||
/**
|
||||
* Returns the rule used after the transition.
|
||||
* @return The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
const TimeZoneRule* getTo(void) const;
|
||||
|
||||
private:
|
||||
UDate fTime;
|
||||
TimeZoneRule* fFrom;
|
||||
TimeZoneRule* fTo;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // TZTRANS_H
|
||||
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef TZTRANS_H
|
||||
#define TZTRANS_H
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: Time zone transition
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/uobject.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
// Forward declaration
|
||||
class TimeZoneRule;
|
||||
|
||||
/**
|
||||
* <code>TimeZoneTransition</code> is a class representing a time zone transition.
|
||||
* An instance has a time of transition and rules for both before and after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API TimeZoneTransition : public UObject {
|
||||
public:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
TimeZoneTransition(const UDate& time, const TimeZoneRule& from, const TimeZoneRule& to);
|
||||
TimeZoneTransition(const UDate& time, TimeZoneRule* from, TimeZoneRule* to);
|
||||
|
||||
/**
|
||||
* Constructs an empty <code>TimeZoneTransition</code>
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition();
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The TimeZoneTransition object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition(const TimeZoneTransition& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
~TimeZoneTransition();
|
||||
|
||||
/**
|
||||
* Clone this TimeZoneTransition object polymorphically. The caller owns the result and
|
||||
* should delete it when done.
|
||||
* @return A copy of the object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition* clone(void) const;
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
TimeZoneTransition& operator=(const TimeZoneTransition& right);
|
||||
|
||||
/**
|
||||
* Return true if the given TimeZoneTransition objects are semantically equal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given TimeZoneTransition objects are semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator==(const TimeZoneTransition& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given TimeZoneTransition objects are semantically unequal. Objects
|
||||
* of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given TimeZoneTransition objects are semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool operator!=(const TimeZoneTransition& that) const;
|
||||
|
||||
/**
|
||||
* Returns the time of transition in milliseconds.
|
||||
* @return The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UDate getTime(void) const;
|
||||
|
||||
/**
|
||||
* Sets the time of transition in milliseconds.
|
||||
* @param time The time of the transition in milliseconds since the 1970 Jan 1 epoch time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTime(UDate time);
|
||||
|
||||
/**
|
||||
* Returns the rule used before the transition.
|
||||
* @return The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
const TimeZoneRule* getFrom(void) const;
|
||||
|
||||
/**
|
||||
* Sets the rule used before the transition. The caller remains
|
||||
* responsible for deleting the <code>TimeZoneRule</code> object.
|
||||
* @param from The time zone rule used before the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setFrom(const TimeZoneRule& from);
|
||||
|
||||
/**
|
||||
* Adopts the rule used before the transition. The caller must
|
||||
* not delete the <code>TimeZoneRule</code> object passed in.
|
||||
* @param from The time zone rule used before the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void adoptFrom(TimeZoneRule* from);
|
||||
|
||||
/**
|
||||
* Sets the rule used after the transition. The caller remains
|
||||
* responsible for deleting the <code>TimeZoneRule</code> object.
|
||||
* @param to The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTo(const TimeZoneRule& to);
|
||||
|
||||
/**
|
||||
* Adopts the rule used after the transition. The caller must
|
||||
* not delete the <code>TimeZoneRule</code> object passed in.
|
||||
* @param to The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void adoptTo(TimeZoneRule* to);
|
||||
|
||||
/**
|
||||
* Returns the rule used after the transition.
|
||||
* @return The time zone rule used after the transition.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
const TimeZoneRule* getTo(void) const;
|
||||
|
||||
private:
|
||||
UDate fTime;
|
||||
TimeZoneRule* fFrom;
|
||||
TimeZoneRule* fTo;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // TZTRANS_H
|
||||
|
||||
//eof
|
||||
|
|
|
@ -1,442 +1,442 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef VTZONE_H
|
||||
#define VTZONE_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: RFC2445 VTIMEZONE support
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/basictz.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class VTZWriter;
|
||||
class VTZReader;
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* <code>VTimeZone</code> is a class implementing RFC2445 VTIMEZONE. You can create a
|
||||
* <code>VTimeZone</code> instance from a time zone ID supported by <code>TimeZone</code>.
|
||||
* With the <code>VTimeZone</code> instance created from the ID, you can write out the rule
|
||||
* in RFC2445 VTIMEZONE format. Also, you can create a <code>VTimeZone</code> instance
|
||||
* from RFC2445 VTIMEZONE data stream, which allows you to calculate time
|
||||
* zone offset by the rules defined by the data.<br><br>
|
||||
* Note: The consumer of this class reading or writing VTIMEZONE data is responsible to
|
||||
* decode or encode Non-ASCII text. Methods reading/writing VTIMEZONE data in this class
|
||||
* do nothing with MIME encoding.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API VTimeZone : public BasicTimeZone {
|
||||
public:
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The <code>VTimeZone</code> object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
VTimeZone(const VTimeZone& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~VTimeZone();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
VTimeZone& operator=(const VTimeZone& right);
|
||||
|
||||
/**
|
||||
* Return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically equal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>VTimeZone</code> objects are
|
||||
*semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator==(const VTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically unequal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator!=(const VTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Create a <code>VTimeZone</code> instance by the time zone ID.
|
||||
* @param ID The time zone ID, such as America/New_York
|
||||
* @return A <code>VTimeZone</code> object initialized by the time zone ID,
|
||||
* or NULL when the ID is unknown.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static VTimeZone* createVTimeZoneByID(const UnicodeString& ID);
|
||||
|
||||
/**
|
||||
* Create a <code>VTimeZone</code> instance by RFC2445 VTIMEZONE data
|
||||
*
|
||||
* @param vtzdata The string including VTIMEZONE data block
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return A <code>VTimeZone</code> initialized by the VTIMEZONE data or
|
||||
* NULL if failed to load the rule from the VTIMEZONE data.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static VTimeZone* createVTimeZone(const UnicodeString& vtzdata, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Gets the RFC2445 TZURL property value. When a <code>VTimeZone</code> instance was
|
||||
* created from VTIMEZONE data, the initial value is set by the TZURL property value
|
||||
* in the data. Otherwise, the initial value is not set.
|
||||
* @param url Receives the RFC2445 TZURL property value.
|
||||
* @return TRUE if TZURL attribute is available and value is set.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool getTZURL(UnicodeString& url) const;
|
||||
|
||||
/**
|
||||
* Sets the RFC2445 TZURL property value.
|
||||
* @param url The TZURL property value.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTZURL(const UnicodeString& url);
|
||||
|
||||
/**
|
||||
* Gets the RFC2445 LAST-MODIFIED property value. When a <code>VTimeZone</code> instance
|
||||
* was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property
|
||||
* value in the data. Otherwise, the initial value is not set.
|
||||
* @param lastModified Receives the last modified date.
|
||||
* @return TRUE if lastModified attribute is available and value is set.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool getLastModified(UDate& lastModified) const;
|
||||
|
||||
/**
|
||||
* Sets the RFC2445 LAST-MODIFIED property value.
|
||||
* @param lastModified The LAST-MODIFIED date.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setLastModified(UDate lastModified);
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data for this time zone
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void write(UnicodeString& result, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data for this time zone applicalbe
|
||||
* for dates after the specified start time.
|
||||
* @param start The start date.
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void write(UDate start, UnicodeString& result, UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data applicalbe for the specified date.
|
||||
* Some common iCalendar implementations can only handle a single time
|
||||
* zone property or a pair of standard and daylight time properties using
|
||||
* BYDAY rule with day of week (such as BYDAY=1SUN). This method produce
|
||||
* the VTIMEZONE data which can be handled these implementations. The rules
|
||||
* produced by this method can be used only for calculating time zone offset
|
||||
* around the specified date.
|
||||
* @param time The date used for rule extraction.
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void writeSimple(UDate time, UnicodeString& result, UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Clones TimeZone objects polymorphically. Clients are responsible for deleting
|
||||
* the TimeZone object cloned.
|
||||
* @return A new copy of this TimeZone object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual TimeZone* clone(void) const;
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time in this time zone, taking daylight savings time into
|
||||
* account) as of a particular reference date. The reference date is used to determine
|
||||
* whether daylight savings time is in effect and needs to be figured into the offset
|
||||
* that is returned (in other words, what is the adjusted GMT offset in this time zone
|
||||
* at this particular date and time?). For the time zones produced by createTimeZone(),
|
||||
* the reference data is specified according to the Gregorian calendar, and the date
|
||||
* and time fields are local standard time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Gets the time zone offset, for current date, modified in case of
|
||||
* daylight savings. This is the offset to add *to* UTC to get local time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param monthLength The length of the given month in days.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
|
||||
uint8_t dayOfWeek, int32_t millis,
|
||||
int32_t monthLength, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns the time zone raw and GMT offset for the given moment
|
||||
* in time. Upon return, local-millis = GMT-millis + rawOffset +
|
||||
* dstOffset. All computations are performed in the proleptic
|
||||
* Gregorian calendar. The default implementation in the TimeZone
|
||||
* class delegates to the 8-argument getOffset().
|
||||
*
|
||||
* @param date moment in time for which to return offsets, in
|
||||
* units of milliseconds from January 1, 1970 0:00 GMT, either GMT
|
||||
* time or local wall time, depending on `local'.
|
||||
* @param local if true, `date' is local wall time; otherwise it
|
||||
* is in GMT time.
|
||||
* @param rawOffset output parameter to receive the raw offset, that
|
||||
* is, the offset not including DST adjustments
|
||||
* @param dstOffset output parameter to receive the DST offset,
|
||||
* that is, the offset to be added to `rawOffset' to obtain the
|
||||
* total offset between local and GMT time. If DST is not in
|
||||
* effect, this value is zero; otherwise it is a positive value,
|
||||
* typically one hour.
|
||||
* @param ec input-output error code
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
|
||||
int32_t& dstOffset, UErrorCode& ec) const;
|
||||
|
||||
/**
|
||||
* Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @param offsetMillis The new raw GMT offset for this time zone.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void setRawOffset(int32_t offsetMillis);
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @return The TimeZone's raw GMT offset.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getRawOffset(void) const;
|
||||
|
||||
/**
|
||||
* Queries if this time zone uses daylight savings time.
|
||||
* @return true if this time zone uses daylight savings time,
|
||||
* false, otherwise.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool useDaylightTime(void) const;
|
||||
|
||||
/**
|
||||
* Queries if the given date is in daylight savings time in
|
||||
* this time zone.
|
||||
* This method is wasteful since it creates a new GregorianCalendar and
|
||||
* deletes it each time it is called. This is a deprecated method
|
||||
* and provided only for Java compatibility.
|
||||
*
|
||||
* @param date the given UDate.
|
||||
* @param status Output param filled in with success/error code.
|
||||
* @return true if the given date is in daylight savings time,
|
||||
* false, otherwise.
|
||||
* @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
|
||||
*/
|
||||
virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns true if this zone has the same rule and offset as another zone.
|
||||
* That is, if this zone differs only in ID, if at all.
|
||||
* @param other the <code>TimeZone</code> object to be compared with
|
||||
* @return true if the given zone is the same as this one,
|
||||
* with the possible exception of the ID
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool hasSameRules(const TimeZone& other) const;
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
|
||||
|
||||
private:
|
||||
enum { DEFAULT_VTIMEZONE_LINES = 100 };
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
VTimeZone();
|
||||
static VTimeZone* createVTimeZone(VTZReader* reader);
|
||||
void write(VTZWriter& writer, UErrorCode& status) const;
|
||||
void write(UDate start, VTZWriter& writer, UErrorCode& status) /*const*/;
|
||||
void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) /*const*/;
|
||||
void load(VTZReader& reader, UErrorCode& status);
|
||||
void parse(UErrorCode& status);
|
||||
|
||||
void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps,
|
||||
UErrorCode& status) const;
|
||||
|
||||
void writeHeaders(VTZWriter& w, UErrorCode& status) const;
|
||||
void writeFooter(VTZWriter& writer, UErrorCode& status) const;
|
||||
|
||||
void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset, UDate time, UErrorCode& status) const;
|
||||
void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime,
|
||||
UErrorCode& status) const;
|
||||
void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth,
|
||||
int32_t dayOfWeek, int32_t numDays,
|
||||
UDate untilTime, int32_t fromOffset, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule,
|
||||
int32_t fromRawOffset, int32_t fromDSTSavings,
|
||||
UDate startTime, UErrorCode& status) const;
|
||||
|
||||
void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const;
|
||||
void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const;
|
||||
void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const;
|
||||
void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const;
|
||||
|
||||
BasicTimeZone *tz;
|
||||
UVector *vtzlines;
|
||||
UnicodeString tzurl;
|
||||
UDate lastmod;
|
||||
UnicodeString olsonzid;
|
||||
UnicodeString icutzver;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // VTZONE_H
|
||||
//eof
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2007, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef VTZONE_H
|
||||
#define VTZONE_H
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
|
||||
/**
|
||||
* \file
|
||||
* \brief C++ API: RFC2445 VTIMEZONE support
|
||||
*/
|
||||
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "unicode/basictz.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class VTZWriter;
|
||||
class VTZReader;
|
||||
class UVector;
|
||||
|
||||
/**
|
||||
* <code>VTimeZone</code> is a class implementing RFC2445 VTIMEZONE. You can create a
|
||||
* <code>VTimeZone</code> instance from a time zone ID supported by <code>TimeZone</code>.
|
||||
* With the <code>VTimeZone</code> instance created from the ID, you can write out the rule
|
||||
* in RFC2445 VTIMEZONE format. Also, you can create a <code>VTimeZone</code> instance
|
||||
* from RFC2445 VTIMEZONE data stream, which allows you to calculate time
|
||||
* zone offset by the rules defined by the data.<br><br>
|
||||
* Note: The consumer of this class reading or writing VTIMEZONE data is responsible to
|
||||
* decode or encode Non-ASCII text. Methods reading/writing VTIMEZONE data in this class
|
||||
* do nothing with MIME encoding.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
class U_I18N_API VTimeZone : public BasicTimeZone {
|
||||
public:
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param source The <code>VTimeZone</code> object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
VTimeZone(const VTimeZone& source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual ~VTimeZone();
|
||||
|
||||
/**
|
||||
* Assignment operator.
|
||||
* @param right The object to be copied.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
VTimeZone& operator=(const VTimeZone& right);
|
||||
|
||||
/**
|
||||
* Return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically equal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>VTimeZone</code> objects are
|
||||
*semantically equal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator==(const VTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically unequal. Objects of different subclasses are considered unequal.
|
||||
* @param that The object to be compared with.
|
||||
* @return true if the given <code>VTimeZone</code> objects are
|
||||
* semantically unequal.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool operator!=(const VTimeZone& that) const;
|
||||
|
||||
/**
|
||||
* Create a <code>VTimeZone</code> instance by the time zone ID.
|
||||
* @param ID The time zone ID, such as America/New_York
|
||||
* @return A <code>VTimeZone</code> object initialized by the time zone ID,
|
||||
* or NULL when the ID is unknown.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static VTimeZone* createVTimeZoneByID(const UnicodeString& ID);
|
||||
|
||||
/**
|
||||
* Create a <code>VTimeZone</code> instance by RFC2445 VTIMEZONE data
|
||||
*
|
||||
* @param vtzdata The string including VTIMEZONE data block
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return A <code>VTimeZone</code> initialized by the VTIMEZONE data or
|
||||
* NULL if failed to load the rule from the VTIMEZONE data.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static VTimeZone* createVTimeZone(const UnicodeString& vtzdata, UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Gets the RFC2445 TZURL property value. When a <code>VTimeZone</code> instance was
|
||||
* created from VTIMEZONE data, the initial value is set by the TZURL property value
|
||||
* in the data. Otherwise, the initial value is not set.
|
||||
* @param url Receives the RFC2445 TZURL property value.
|
||||
* @return TRUE if TZURL attribute is available and value is set.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool getTZURL(UnicodeString& url) const;
|
||||
|
||||
/**
|
||||
* Sets the RFC2445 TZURL property value.
|
||||
* @param url The TZURL property value.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setTZURL(const UnicodeString& url);
|
||||
|
||||
/**
|
||||
* Gets the RFC2445 LAST-MODIFIED property value. When a <code>VTimeZone</code> instance
|
||||
* was created from VTIMEZONE data, the initial value is set by the LAST-MODIFIED property
|
||||
* value in the data. Otherwise, the initial value is not set.
|
||||
* @param lastModified Receives the last modified date.
|
||||
* @return TRUE if lastModified attribute is available and value is set.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
UBool getLastModified(UDate& lastModified) const;
|
||||
|
||||
/**
|
||||
* Sets the RFC2445 LAST-MODIFIED property value.
|
||||
* @param lastModified The LAST-MODIFIED date.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void setLastModified(UDate lastModified);
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data for this time zone
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void write(UnicodeString& result, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data for this time zone applicalbe
|
||||
* for dates after the specified start time.
|
||||
* @param start The start date.
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void write(UDate start, UnicodeString& result, UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Writes RFC2445 VTIMEZONE data applicalbe for the specified date.
|
||||
* Some common iCalendar implementations can only handle a single time
|
||||
* zone property or a pair of standard and daylight time properties using
|
||||
* BYDAY rule with day of week (such as BYDAY=1SUN). This method produce
|
||||
* the VTIMEZONE data which can be handled these implementations. The rules
|
||||
* produced by this method can be used only for calculating time zone offset
|
||||
* around the specified date.
|
||||
* @param time The date used for rule extraction.
|
||||
* @param result Output param to filled in with the VTIMEZONE data.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
void writeSimple(UDate time, UnicodeString& result, UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Clones TimeZone objects polymorphically. Clients are responsible for deleting
|
||||
* the TimeZone object cloned.
|
||||
* @return A new copy of this TimeZone object.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual TimeZone* clone(void) const;
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's adjusted GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time in this time zone, taking daylight savings time into
|
||||
* account) as of a particular reference date. The reference date is used to determine
|
||||
* whether daylight savings time is in effect and needs to be figured into the offset
|
||||
* that is returned (in other words, what is the adjusted GMT offset in this time zone
|
||||
* at this particular date and time?). For the time zones produced by createTimeZone(),
|
||||
* the reference data is specified according to the Gregorian calendar, and the date
|
||||
* and time fields are local standard time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Gets the time zone offset, for current date, modified in case of
|
||||
* daylight savings. This is the offset to add *to* UTC to get local time.
|
||||
*
|
||||
* <p>Note: Don't call this method. Instead, call the getOffset(UDate...) overload,
|
||||
* which returns both the raw and the DST offset for a given time. This method
|
||||
* is retained only for backward compatibility.
|
||||
*
|
||||
* @param era The reference date's era
|
||||
* @param year The reference date's year
|
||||
* @param month The reference date's month (0-based; 0 is January)
|
||||
* @param day The reference date's day-in-month (1-based)
|
||||
* @param dayOfWeek The reference date's day-of-week (1-based; 1 is Sunday)
|
||||
* @param millis The reference date's milliseconds in day, local standard time
|
||||
* @param monthLength The length of the given month in days.
|
||||
* @param status Output param to filled in with a success or an error.
|
||||
* @return The offset in milliseconds to add to GMT to get local time.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
|
||||
uint8_t dayOfWeek, int32_t millis,
|
||||
int32_t monthLength, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns the time zone raw and GMT offset for the given moment
|
||||
* in time. Upon return, local-millis = GMT-millis + rawOffset +
|
||||
* dstOffset. All computations are performed in the proleptic
|
||||
* Gregorian calendar. The default implementation in the TimeZone
|
||||
* class delegates to the 8-argument getOffset().
|
||||
*
|
||||
* @param date moment in time for which to return offsets, in
|
||||
* units of milliseconds from January 1, 1970 0:00 GMT, either GMT
|
||||
* time or local wall time, depending on `local'.
|
||||
* @param local if true, `date' is local wall time; otherwise it
|
||||
* is in GMT time.
|
||||
* @param rawOffset output parameter to receive the raw offset, that
|
||||
* is, the offset not including DST adjustments
|
||||
* @param dstOffset output parameter to receive the DST offset,
|
||||
* that is, the offset to be added to `rawOffset' to obtain the
|
||||
* total offset between local and GMT time. If DST is not in
|
||||
* effect, this value is zero; otherwise it is a positive value,
|
||||
* typically one hour.
|
||||
* @param ec input-output error code
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
|
||||
int32_t& dstOffset, UErrorCode& ec) const;
|
||||
|
||||
/**
|
||||
* Sets the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @param offsetMillis The new raw GMT offset for this time zone.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void setRawOffset(int32_t offsetMillis);
|
||||
|
||||
/**
|
||||
* Returns the TimeZone's raw GMT offset (i.e., the number of milliseconds to add
|
||||
* to GMT to get local time, before taking daylight savings time into account).
|
||||
*
|
||||
* @return The TimeZone's raw GMT offset.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t getRawOffset(void) const;
|
||||
|
||||
/**
|
||||
* Queries if this time zone uses daylight savings time.
|
||||
* @return true if this time zone uses daylight savings time,
|
||||
* false, otherwise.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool useDaylightTime(void) const;
|
||||
|
||||
/**
|
||||
* Queries if the given date is in daylight savings time in
|
||||
* this time zone.
|
||||
* This method is wasteful since it creates a new GregorianCalendar and
|
||||
* deletes it each time it is called. This is a deprecated method
|
||||
* and provided only for Java compatibility.
|
||||
*
|
||||
* @param date the given UDate.
|
||||
* @param status Output param filled in with success/error code.
|
||||
* @return true if the given date is in daylight savings time,
|
||||
* false, otherwise.
|
||||
* @deprecated ICU 2.4. Use Calendar::inDaylightTime() instead.
|
||||
*/
|
||||
virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
|
||||
|
||||
/**
|
||||
* Returns true if this zone has the same rule and offset as another zone.
|
||||
* That is, if this zone differs only in ID, if at all.
|
||||
* @param other the <code>TimeZone</code> object to be compared with
|
||||
* @return true if the given zone is the same as this one,
|
||||
* with the possible exception of the ID
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
virtual UBool hasSameRules(const TimeZone& other) const;
|
||||
|
||||
/**
|
||||
* Gets the first time zone transition after the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the first transition after the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the most recent time zone transition before the base time.
|
||||
* @param base The base time.
|
||||
* @param inclusive Whether the base time is inclusive or not.
|
||||
* @param result Receives the most recent transition before the base time.
|
||||
* @return TRUE if the transition is found.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/;
|
||||
|
||||
/**
|
||||
* Returns the number of <code>TimeZoneRule</code>s which represents time transitions,
|
||||
* for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except
|
||||
* <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value.
|
||||
* @param status Receives error status code.
|
||||
* @return The number of <code>TimeZoneRule</code>s representing time transitions.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual int32_t countTransitionRules(UErrorCode& status) /*const*/;
|
||||
|
||||
/**
|
||||
* Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code>
|
||||
* which represent time transitions for this time zone. On successful return,
|
||||
* the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and
|
||||
* the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code>
|
||||
* instances up to the size specified by trscount. The results are referencing the
|
||||
* rule instance held by this time zone instance. Therefore, after this time zone
|
||||
* is destructed, they are no longer available.
|
||||
* @param initial Receives the initial timezone rule
|
||||
* @param trsrules Receives the timezone transition rules
|
||||
* @param trscount On input, specify the size of the array 'transitions' receiving
|
||||
* the timezone transition rules. On output, actual number of
|
||||
* rules filled in the array will be set.
|
||||
* @param status Receives error status code.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial,
|
||||
const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) /*const*/;
|
||||
|
||||
private:
|
||||
enum { DEFAULT_VTIMEZONE_LINES = 100 };
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
VTimeZone();
|
||||
static VTimeZone* createVTimeZone(VTZReader* reader);
|
||||
void write(VTZWriter& writer, UErrorCode& status) const;
|
||||
void write(UDate start, VTZWriter& writer, UErrorCode& status) /*const*/;
|
||||
void writeSimple(UDate time, VTZWriter& writer, UErrorCode& status) /*const*/;
|
||||
void load(VTZReader& reader, UErrorCode& status);
|
||||
void parse(UErrorCode& status);
|
||||
|
||||
void writeZone(VTZWriter& w, BasicTimeZone& basictz, UVector* customProps,
|
||||
UErrorCode& status) const;
|
||||
|
||||
void writeHeaders(VTZWriter& w, UErrorCode& status) const;
|
||||
void writeFooter(VTZWriter& writer, UErrorCode& status) const;
|
||||
|
||||
void writeZonePropsByTime(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset, UDate time, UErrorCode& status) const;
|
||||
void writeZonePropsByDOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, UDate startTime, UDate untilTime,
|
||||
UErrorCode& status) const;
|
||||
void writeZonePropsByDOW(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_GEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_GEQ_DOM_sub(VTZWriter& writer, int32_t month, int32_t dayOfMonth,
|
||||
int32_t dayOfWeek, int32_t numDays,
|
||||
UDate untilTime, int32_t fromOffset, UErrorCode& status) const;
|
||||
void writeZonePropsByDOW_LEQ_DOM(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset,
|
||||
int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
|
||||
UDate startTime, UDate untilTime, UErrorCode& status) const;
|
||||
void writeFinalRule(VTZWriter& writer, UBool isDst, const AnnualTimeZoneRule* rule,
|
||||
int32_t fromRawOffset, int32_t fromDSTSavings,
|
||||
UDate startTime, UErrorCode& status) const;
|
||||
|
||||
void beginZoneProps(VTZWriter& writer, UBool isDst, const UnicodeString& tzname,
|
||||
int32_t fromOffset, int32_t toOffset, UDate startTime, UErrorCode& status) const;
|
||||
void endZoneProps(VTZWriter& writer, UBool isDst, UErrorCode& status) const;
|
||||
void beginRRULE(VTZWriter& writer, int32_t month, UErrorCode& status) const;
|
||||
void appendUNTIL(VTZWriter& writer, const UnicodeString& until, UErrorCode& status) const;
|
||||
|
||||
BasicTimeZone *tz;
|
||||
UVector *vtzlines;
|
||||
UnicodeString tzurl;
|
||||
UDate lastmod;
|
||||
UnicodeString olsonzid;
|
||||
UnicodeString icutzver;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Return the class ID for this class. This is useful only for comparing to
|
||||
* a return value from getDynamicClassID(). For example:
|
||||
* <pre>
|
||||
* . Base* polymorphic_pointer = createPolymorphicObject();
|
||||
* . if (polymorphic_pointer->getDynamicClassID() ==
|
||||
* . erived::getStaticClassID()) ...
|
||||
* </pre>
|
||||
* @return The class ID for all objects of this class.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
static UClassID U_EXPORT2 getStaticClassID(void);
|
||||
|
||||
/**
|
||||
* Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
||||
* method is to implement a simple version of RTTI, since not all C++
|
||||
* compilers support genuine RTTI. Polymorphic operator==() and clone()
|
||||
* methods call this method.
|
||||
*
|
||||
* @return The class ID for this object. All objects of a
|
||||
* given class have the same class ID. Objects of
|
||||
* other classes have different class IDs.
|
||||
* @draft ICU 3.8
|
||||
*/
|
||||
virtual UClassID getDynamicClassID(void) const;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
#endif /* #if !UCONFIG_NO_FORMATTING */
|
||||
|
||||
#endif // VTZONE_H
|
||||
//eof
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue