summaryrefslogtreecommitdiffstats
path: root/i18npool/source/calendar/calendar_gregorian.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'i18npool/source/calendar/calendar_gregorian.cxx')
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx828
1 files changed, 414 insertions, 414 deletions
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index dddeea78f65b..ecb912fb94d3 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -137,66 +137,66 @@ Calendar_gregorian::Calendar_gregorian(const Era *_earArray)
void SAL_CALL
Calendar_gregorian::init(const Era *_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_gregorian";
-
- // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
- // th_TH system locale we accidentally used a Buddhist calendar. Though
- // the ICU documentation says that should be the case only for
- // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
- // already triggers that behavior, ja_JP does not. Strange enough,
- // passing a th_TH locale to the calendar creation doesn't trigger
- // this.
- // See also http://userguide.icu-project.org/datetime/calendar
-
- // Whatever ICU offers as the default calendar for a locale, ensure we
- // have a Gregorian calendar as requested.
-
- /* XXX: with the current implementation the aLocale member variable is
- * not set prior to loading a calendar from locale data. This
- * creates an empty (root) locale for ICU, but at least the correct
- * calendar is used. The language part must not be NULL (respectively
- * not all, language and country and variant), otherwise the current
- * default locale would be used again and the calendar keyword ignored.
- * */
- icu::Locale aIcuLocale( "", NULL, NULL, "calendar=gregorian");
+ cCalendar = "com.sun.star.i18n.Calendar_gregorian";
+
+ // #i102356# With icu::Calendar::createInstance(UErrorCode) in a Thai
+ // th_TH system locale we accidentally used a Buddhist calendar. Though
+ // the ICU documentation says that should be the case only for
+ // th_TH_TRADITIONAL (and ja_JP_TRADITIONAL Gengou), a plain th_TH
+ // already triggers that behavior, ja_JP does not. Strange enough,
+ // passing a th_TH locale to the calendar creation doesn't trigger
+ // this.
+ // See also http://userguide.icu-project.org/datetime/calendar
+
+ // Whatever ICU offers as the default calendar for a locale, ensure we
+ // have a Gregorian calendar as requested.
+
+ /* XXX: with the current implementation the aLocale member variable is
+ * not set prior to loading a calendar from locale data. This
+ * creates an empty (root) locale for ICU, but at least the correct
+ * calendar is used. The language part must not be NULL (respectively
+ * not all, language and country and variant), otherwise the current
+ * default locale would be used again and the calendar keyword ignored.
+ * */
+ icu::Locale aIcuLocale( "", NULL, NULL, "calendar=gregorian");
- UErrorCode status;
- body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
- if (!body || !U_SUCCESS(status)) throw ERROR;
- eraArray=_eraArray;
+ UErrorCode status;
+ body = icu::Calendar::createInstance( aIcuLocale, status = U_ZERO_ERROR);
+ if (!body || !U_SUCCESS(status)) throw ERROR;
+ eraArray=_eraArray;
}
Calendar_gregorian::~Calendar_gregorian()
{
- delete body;
+ delete body;
}
Calendar_hanja::Calendar_hanja()
{
- cCalendar = "com.sun.star.i18n.Calendar_hanja";
+ cCalendar = "com.sun.star.i18n.Calendar_hanja";
}
OUString SAL_CALL
Calendar_hanja::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
- if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
- // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
- com::sun::star::lang::Locale jaLocale =
- com::sun::star::lang::Locale(OUString("ja"), OUString(), OUString());
- if (idx == 0) return LocaleDataImpl().getLocaleItem(jaLocale).timeAM;
- else if (idx == 1) return LocaleDataImpl().getLocaleItem(jaLocale).timePM;
- else throw ERROR;
- }
- else
- return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
+ if ( displayIndex == CalendarDisplayIndex::AM_PM ) {
+ // Am/Pm string for Korean Hanja calendar will refer to Japanese locale
+ com::sun::star::lang::Locale jaLocale =
+ com::sun::star::lang::Locale(OUString("ja"), OUString(), OUString());
+ if (idx == 0) return LocaleDataImpl().getLocaleItem(jaLocale).timeAM;
+ else if (idx == 1) return LocaleDataImpl().getLocaleItem(jaLocale).timePM;
+ else throw ERROR;
+ }
+ else
+ return Calendar_gregorian::getDisplayName( displayIndex, idx, nameType );
}
void SAL_CALL
Calendar_hanja::loadCalendar( const OUString& /*uniqueID*/, const com::sun::star::lang::Locale& rLocale ) throw(RuntimeException)
{
- // Since this class could be called by service name 'hanja_yoil', we have to
- // rename uniqueID to get right calendar defined in locale data.
- Calendar_gregorian::loadCalendar(OUString("hanja"), rLocale);
+ // Since this class could be called by service name 'hanja_yoil', we have to
+ // rename uniqueID to get right calendar defined in locale data.
+ Calendar_gregorian::loadCalendar(OUString("hanja"), rLocale);
}
static const Era gengou_eraArray[] = {
@@ -208,7 +208,7 @@ static const Era gengou_eraArray[] = {
};
Calendar_gengou::Calendar_gengou() : Calendar_gregorian(gengou_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_gengou";
+ cCalendar = "com.sun.star.i18n.Calendar_gengou";
}
static const Era ROC_eraArray[] = {
@@ -217,7 +217,7 @@ static const Era ROC_eraArray[] = {
};
Calendar_ROC::Calendar_ROC() : Calendar_gregorian(ROC_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_ROC";
+ cCalendar = "com.sun.star.i18n.Calendar_ROC";
}
static const Era buddhist_eraArray[] = {
@@ -226,118 +226,118 @@ static const Era buddhist_eraArray[] = {
};
Calendar_buddhist::Calendar_buddhist() : Calendar_gregorian(buddhist_eraArray)
{
- cCalendar = "com.sun.star.i18n.Calendar_buddhist";
+ cCalendar = "com.sun.star.i18n.Calendar_buddhist";
}
void SAL_CALL
Calendar_gregorian::loadCalendar( const OUString& uniqueID, const com::sun::star::lang::Locale& rLocale ) throw(RuntimeException)
{
- // init. fieldValue[]
- getValue();
+ // init. fieldValue[]
+ getValue();
- aLocale = rLocale;
- Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale);
- for (sal_Int32 i = 0; i < xC.getLength(); i++)
+ aLocale = rLocale;
+ Sequence< Calendar2 > xC = LocaleDataImpl().getAllCalendars2(rLocale);
+ for (sal_Int32 i = 0; i < xC.getLength(); i++)
+ {
+ if (uniqueID == xC[i].Name)
{
- if (uniqueID == xC[i].Name)
+ aCalendar = xC[i];
+ // setup minimalDaysInFirstWeek
+ setMinimumNumberOfDaysForFirstWeek(
+ aCalendar.MinimumNumberOfDaysForFirstWeek);
+ // setup first day of week
+ for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
+ aCalendar.Days.getLength()-1); day>=0; day--)
{
- aCalendar = xC[i];
- // setup minimalDaysInFirstWeek
- setMinimumNumberOfDaysForFirstWeek(
- aCalendar.MinimumNumberOfDaysForFirstWeek);
- // setup first day of week
- for (sal_Int16 day = sal::static_int_cast<sal_Int16>(
- aCalendar.Days.getLength()-1); day>=0; day--)
+ if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
{
- if (aCalendar.StartOfWeek == aCalendar.Days[day].ID)
- {
- setFirstDayOfWeek( day);
- return;
- }
+ setFirstDayOfWeek( day);
+ return;
}
}
}
- // Calendar is not for the locale
- throw ERROR;
+ }
+ // Calendar is not for the locale
+ throw ERROR;
}
com::sun::star::i18n::Calendar2 SAL_CALL
Calendar_gregorian::getLoadedCalendar2() throw(RuntimeException)
{
- return aCalendar;
+ return aCalendar;
}
com::sun::star::i18n::Calendar SAL_CALL
Calendar_gregorian::getLoadedCalendar() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendar( aCalendar);
+ return LocaleDataImpl::downcastCalendar( aCalendar);
}
OUString SAL_CALL
Calendar_gregorian::getUniqueID() throw(RuntimeException)
{
- return aCalendar.Name;
+ return aCalendar.Name;
}
void SAL_CALL
Calendar_gregorian::setDateTime( double timeInDays ) throw(RuntimeException)
{
- // ICU handles dates in milliseconds as double values and uses floor()
- // to obtain integer values, which may yield a date decremented by one
- // for odd (historical) timezone values where the computed value due to
- // rounding errors has a fractional part in milliseconds. Ensure we
- // pass a value without fraction here. If not, that may lead to
- // fdo#44286 or fdo#52619 and the like, e.g. when passing
- // -2136315212000.000244 instead of -2136315212000.000000
- double fM = timeInDays * U_MILLIS_PER_DAY;
- double fR = rtl::math::round( fM );
- SAL_INFO_IF( fM != fR, "i18npool",
- "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
- UErrorCode status;
- body->setTime( fR, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- getValue();
+ // ICU handles dates in milliseconds as double values and uses floor()
+ // to obtain integer values, which may yield a date decremented by one
+ // for odd (historical) timezone values where the computed value due to
+ // rounding errors has a fractional part in milliseconds. Ensure we
+ // pass a value without fraction here. If not, that may lead to
+ // fdo#44286 or fdo#52619 and the like, e.g. when passing
+ // -2136315212000.000244 instead of -2136315212000.000000
+ double fM = timeInDays * U_MILLIS_PER_DAY;
+ double fR = rtl::math::round( fM );
+ SAL_INFO_IF( fM != fR, "i18npool",
+ "Calendar_gregorian::setDateTime: " << std::fixed << fM << " rounded to " << fR);
+ UErrorCode status;
+ body->setTime( fR, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ getValue();
}
double SAL_CALL
Calendar_gregorian::getDateTime() throw(RuntimeException)
{
- if (fieldSet) {
- setValue();
- getValue();
- }
- UErrorCode status;
- double r = body->getTime(status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- return r / U_MILLIS_PER_DAY;
+ if (fieldSet) {
+ setValue();
+ getValue();
+ }
+ UErrorCode status;
+ double r = body->getTime(status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ return r / U_MILLIS_PER_DAY;
}
// map field value from gregorian calendar to other calendar, it can be overwritten by derived class.
// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
void Calendar_gregorian::mapFromGregorian() throw(RuntimeException)
{
- if (eraArray) {
- sal_Int16 e, y, m, d;
+ if (eraArray) {
+ sal_Int16 e, y, m, d;
- e = fieldValue[CalendarFieldIndex::ERA];
- y = fieldValue[CalendarFieldIndex::YEAR];
- m = fieldValue[CalendarFieldIndex::MONTH] + 1;
- d = fieldValue[CalendarFieldIndex::DAY_OF_MONTH];
+ e = fieldValue[CalendarFieldIndex::ERA];
+ y = fieldValue[CalendarFieldIndex::YEAR];
+ m = fieldValue[CalendarFieldIndex::MONTH] + 1;
+ d = fieldValue[CalendarFieldIndex::DAY_OF_MONTH];
- // since the year is reversed for first era, it is reversed again here for Era compare.
- if (e == 0)
- y = 1 - y;
+ // since the year is reversed for first era, it is reversed again here for Era compare.
+ if (e == 0)
+ y = 1 - y;
- for (e = 0; eraArray[e].year; e++)
- if ((y != eraArray[e].year) ? y < eraArray[e].year :
+ for (e = 0; eraArray[e].year; e++)
+ if ((y != eraArray[e].year) ? y < eraArray[e].year :
(m != eraArray[e].month) ? m < eraArray[e].month : d < eraArray[e].day)
- break;
+ break;
- fieldValue[CalendarFieldIndex::ERA] = e;
- fieldValue[CalendarFieldIndex::YEAR] =
- sal::static_int_cast<sal_Int16>( (e == 0) ? (eraArray[0].year - y) : (y - eraArray[e-1].year + 1) );
- }
+ fieldValue[CalendarFieldIndex::ERA] = e;
+ fieldValue[CalendarFieldIndex::YEAR] =
+ sal::static_int_cast<sal_Int16>( (e == 0) ? (eraArray[0].year - y) : (y - eraArray[e-1].year + 1) );
+ }
}
#define FIELDS ((1 << CalendarFieldIndex::ERA) | (1 << CalendarFieldIndex::YEAR))
@@ -345,42 +345,42 @@ void Calendar_gregorian::mapFromGregorian() throw(RuntimeException)
// By using eraArray, it can take care Japanese and Taiwan ROC calendar.
void Calendar_gregorian::mapToGregorian() throw(RuntimeException)
{
- if (eraArray && (fieldSet & FIELDS)) {
- sal_Int16 y, e = fieldValue[CalendarFieldIndex::ERA];
- if (e == 0)
- y = sal::static_int_cast<sal_Int16>( eraArray[0].year - fieldValue[CalendarFieldIndex::YEAR] );
- else
- y = sal::static_int_cast<sal_Int16>( eraArray[e-1].year + fieldValue[CalendarFieldIndex::YEAR] - 1 );
-
- fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1;
- fieldSetValue[CalendarFieldIndex::YEAR] = (y <= 0 ? 1 - y : y);
- fieldSet |= FIELDS;
- }
+ if (eraArray && (fieldSet & FIELDS)) {
+ sal_Int16 y, e = fieldValue[CalendarFieldIndex::ERA];
+ if (e == 0)
+ y = sal::static_int_cast<sal_Int16>( eraArray[0].year - fieldValue[CalendarFieldIndex::YEAR] );
+ else
+ y = sal::static_int_cast<sal_Int16>( eraArray[e-1].year + fieldValue[CalendarFieldIndex::YEAR] - 1 );
+
+ fieldSetValue[CalendarFieldIndex::ERA] = y <= 0 ? 0 : 1;
+ fieldSetValue[CalendarFieldIndex::YEAR] = (y <= 0 ? 1 - y : y);
+ fieldSet |= FIELDS;
+ }
}
static UCalendarDateFields fieldNameConverter(sal_Int16 fieldIndex) throw(RuntimeException)
{
- UCalendarDateFields f;
-
- switch (fieldIndex) {
- case CalendarFieldIndex::AM_PM: f = UCAL_AM_PM; break;
- case CalendarFieldIndex::DAY_OF_MONTH: f = UCAL_DATE; break;
- case CalendarFieldIndex::DAY_OF_WEEK: f = UCAL_DAY_OF_WEEK; break;
- case CalendarFieldIndex::DAY_OF_YEAR: f = UCAL_DAY_OF_YEAR; break;
- case CalendarFieldIndex::DST_OFFSET: f = UCAL_DST_OFFSET; break;
- case CalendarFieldIndex::ZONE_OFFSET: f = UCAL_ZONE_OFFSET; break;
- case CalendarFieldIndex::HOUR: f = UCAL_HOUR_OF_DAY; break;
- case CalendarFieldIndex::MINUTE: f = UCAL_MINUTE; break;
- case CalendarFieldIndex::SECOND: f = UCAL_SECOND; break;
- case CalendarFieldIndex::MILLISECOND: f = UCAL_MILLISECOND; break;
- case CalendarFieldIndex::WEEK_OF_MONTH: f = UCAL_WEEK_OF_MONTH; break;
- case CalendarFieldIndex::WEEK_OF_YEAR: f = UCAL_WEEK_OF_YEAR; break;
- case CalendarFieldIndex::YEAR: f = UCAL_YEAR; break;
- case CalendarFieldIndex::MONTH: f = UCAL_MONTH; break;
- case CalendarFieldIndex::ERA: f = UCAL_ERA; break;
- default: throw ERROR;
- }
- return f;
+ UCalendarDateFields f;
+
+ switch (fieldIndex) {
+ case CalendarFieldIndex::AM_PM: f = UCAL_AM_PM; break;
+ case CalendarFieldIndex::DAY_OF_MONTH: f = UCAL_DATE; break;
+ case CalendarFieldIndex::DAY_OF_WEEK: f = UCAL_DAY_OF_WEEK; break;
+ case CalendarFieldIndex::DAY_OF_YEAR: f = UCAL_DAY_OF_YEAR; break;
+ case CalendarFieldIndex::DST_OFFSET: f = UCAL_DST_OFFSET; break;
+ case CalendarFieldIndex::ZONE_OFFSET: f = UCAL_ZONE_OFFSET; break;
+ case CalendarFieldIndex::HOUR: f = UCAL_HOUR_OF_DAY; break;
+ case CalendarFieldIndex::MINUTE: f = UCAL_MINUTE; break;
+ case CalendarFieldIndex::SECOND: f = UCAL_SECOND; break;
+ case CalendarFieldIndex::MILLISECOND: f = UCAL_MILLISECOND; break;
+ case CalendarFieldIndex::WEEK_OF_MONTH: f = UCAL_WEEK_OF_MONTH; break;
+ case CalendarFieldIndex::WEEK_OF_YEAR: f = UCAL_WEEK_OF_YEAR; break;
+ case CalendarFieldIndex::YEAR: f = UCAL_YEAR; break;
+ case CalendarFieldIndex::MONTH: f = UCAL_MONTH; break;
+ case CalendarFieldIndex::ERA: f = UCAL_ERA; break;
+ default: throw ERROR;
+ }
+ return f;
}
void SAL_CALL
@@ -491,220 +491,220 @@ static void lcl_setCombinedOffsetFieldValues( sal_Int32 nValue,
void Calendar_gregorian::setValue() throw(RuntimeException)
{
- // Correct DST glitch, see also localtime/gmtime conversion pitfalls at
- // http://www.erack.de/download/timetest.c
- //
- // #i24082# in order to make the DST correction work in all
- // circumstances, the time values have to be always resubmitted,
- // regardless whether specified by the caller or not. It is not
- // sufficient to rely on the ICU internal values previously set, as the
- // following may happen:
- // - Let 2004-03-28T02:00 be the onsetRule.
- // - On 2004-03-29 (calendar initialized with 2004-03-29T00:00 DST) set
- // a date of 2004-03-28 => calendar results in 2004-03-27T23:00 no DST.
- // - Correcting this with simply "2004-03-28 no DST" and no time
- // specified results in 2004-03-29T00:00, the ICU internal 23:00 time
- // being adjusted to 24:00 in this case, switching one day further.
- // => submit 2004-03-28T00:00 no DST.
-
- // This got even weirder since ICU incorporated also historical data,
- // even the timezone may differ for different dates! It is necessary to
- // let ICU choose the corresponding OlsonTimeZone transitions and adapt
- // values.
- // #i86094# gives examples where that went wrong:
- // TZ=Europe/Moscow date <= 1919-07-01
- // zone +2:30:48 (!) instead of +3h, DST +2h instead of +1h
- // TZ=America/St_Johns date <= 1935-03-30
- // zone -3:30:52 (!) instead of -3:30
-
- // Copy fields before calling submitFields() directly or indirectly below.
- memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
- // Possibly setup ERA and YEAR in fieldSetValue.
- mapToGregorian();
-
- DUMP_ICU_CAL_MSG(("%s\n","setValue() before any submission"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() before any submission"));
-
- bool bNeedZone = !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET));
- bool bNeedDST = !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET));
- sal_Int32 nZone1, nDST1, nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0;
- nZone1 = nDST1 = nZone0 = nDST0 = 0;
- nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
- if ( bNeedZone || bNeedDST )
+ // Correct DST glitch, see also localtime/gmtime conversion pitfalls at
+ // http://www.erack.de/download/timetest.c
+ //
+ // #i24082# in order to make the DST correction work in all
+ // circumstances, the time values have to be always resubmitted,
+ // regardless whether specified by the caller or not. It is not
+ // sufficient to rely on the ICU internal values previously set, as the
+ // following may happen:
+ // - Let 2004-03-28T02:00 be the onsetRule.
+ // - On 2004-03-29 (calendar initialized with 2004-03-29T00:00 DST) set
+ // a date of 2004-03-28 => calendar results in 2004-03-27T23:00 no DST.
+ // - Correcting this with simply "2004-03-28 no DST" and no time
+ // specified results in 2004-03-29T00:00, the ICU internal 23:00 time
+ // being adjusted to 24:00 in this case, switching one day further.
+ // => submit 2004-03-28T00:00 no DST.
+
+ // This got even weirder since ICU incorporated also historical data,
+ // even the timezone may differ for different dates! It is necessary to
+ // let ICU choose the corresponding OlsonTimeZone transitions and adapt
+ // values.
+ // #i86094# gives examples where that went wrong:
+ // TZ=Europe/Moscow date <= 1919-07-01
+ // zone +2:30:48 (!) instead of +3h, DST +2h instead of +1h
+ // TZ=America/St_Johns date <= 1935-03-30
+ // zone -3:30:52 (!) instead of -3:30
+
+ // Copy fields before calling submitFields() directly or indirectly below.
+ memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
+ // Possibly setup ERA and YEAR in fieldSetValue.
+ mapToGregorian();
+
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() before any submission"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() before any submission"));
+
+ bool bNeedZone = !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET));
+ bool bNeedDST = !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET));
+ sal_Int32 nZone1, nDST1, nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0;
+ nZone1 = nDST1 = nZone0 = nDST0 = 0;
+ nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
+ if ( bNeedZone || bNeedDST )
+ {
+ UErrorCode status;
+ if ( !(fieldSet & (1 << CalendarFieldIndex::YEAR)) )
{
- UErrorCode status;
- if ( !(fieldSet & (1 << CalendarFieldIndex::YEAR)) )
- {
- nYear = body->get( UCAL_YEAR, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nYear = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MONTH)) )
- {
- nMonth = body->get( UCAL_MONTH, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMonth = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::DAY_OF_MONTH)) )
- {
- nDay = body->get( UCAL_DATE, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDay = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::HOUR)) )
- {
- nHour = body->get( UCAL_HOUR_OF_DAY, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nHour = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MINUTE)) )
- {
- nMinute = body->get( UCAL_MINUTE, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMinute = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::SECOND)) )
- {
- nSecond = body->get( UCAL_SECOND, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nSecond = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::MILLISECOND)) )
- {
- nMilliSecond = body->get( UCAL_MILLISECOND, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nMilliSecond = -1;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET)) )
- {
- nZone0 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nZone0 = 0;
- }
- if ( !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET)) )
- {
- nDST0 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST0 = 0;
- }
-
- // Submit values to obtain a time zone and DST corresponding to the date/time.
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0);
-
- DUMP_ICU_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
- nZone1 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ nYear = body->get( UCAL_YEAR, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nYear = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MONTH)) )
+ {
+ nMonth = body->get( UCAL_MONTH, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMonth = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::DAY_OF_MONTH)) )
+ {
+ nDay = body->get( UCAL_DATE, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nZone1 = 0;
- nDST1 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ nDay = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::HOUR)) )
+ {
+ nHour = body->get( UCAL_HOUR_OF_DAY, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nDST1 = 0;
+ nHour = -1;
}
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MINUTE)) )
+ {
+ nMinute = body->get( UCAL_MINUTE, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMinute = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::SECOND)) )
+ {
+ nSecond = body->get( UCAL_SECOND, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nSecond = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::MILLISECOND)) )
+ {
+ nMilliSecond = body->get( UCAL_MILLISECOND, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nMilliSecond = -1;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::ZONE_OFFSET)) )
+ {
+ nZone0 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone0 = 0;
+ }
+ if ( !(fieldSet & (1 << CalendarFieldIndex::DST_OFFSET)) )
+ {
+ nDST0 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST0 = 0;
+ }
+
+ // Submit values to obtain a time zone and DST corresponding to the date/time.
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0);
+
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() in bNeedZone||bNeedDST after submitValues()"));
+ nZone1 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone1 = 0;
+ nDST1 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST1 = 0;
+ }
- // The original submission, may lead to a different zone/DST and
- // different date.
- submitFields();
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after original submission"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after original submission"));
+ // The original submission, may lead to a different zone/DST and
+ // different date.
+ submitFields();
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after original submission"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after original submission"));
- if ( bNeedZone || bNeedDST )
+ if ( bNeedZone || bNeedDST )
+ {
+ UErrorCode status;
+ sal_Int32 nZone2 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nZone2 = nZone1;
+ sal_Int32 nDST2 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST2 = nDST1;
+ if ( nZone0 != nZone1 || nZone2 != nZone1 || nDST0 != nDST1 || nDST2 != nDST1 )
{
- UErrorCode status;
- sal_Int32 nZone2 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
+ // Due to different DSTs, resulting date values may differ if
+ // DST is onset at 00:00 and the very onsetRule date was
+ // submitted with DST off => date-1 23:00, for example, which
+ // is not what we want.
+ // Resubmit all values, this time including DST => date 01:00
+ // Similar for zone differences.
+ // If already the first full submission with nZone0 and nDST0
+ // lead to date-1 23:00, the original submission was based on
+ // that date if it wasn't a full date (nDST0 set, nDST1 not
+ // set, nDST2==nDST1). If it was January 1st without year we're
+ // even off by one year now. Resubmit all values including new
+ // DST => date 00:00.
+
+ // Set field values accordingly in case they were used.
+ if (!bNeedZone)
+ lcl_setCombinedOffsetFieldValues( nZone2, fieldSetValue,
+ fieldValue, CalendarFieldIndex::ZONE_OFFSET,
+ CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
+ if (!bNeedDST)
+ lcl_setCombinedOffsetFieldValues( nDST2, fieldSetValue,
+ fieldValue, CalendarFieldIndex::DST_OFFSET,
+ CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone2, nDST2);
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
+
+ // Time zone transition => resubmit.
+ // TZ=America/St_Johns date <= 1935-03-30
+ // -3:30:52 (!) instead of -3:30
+ // if first submission included time zone -3:30 that would be wrong.
+ bool bResubmit = false;
+ sal_Int32 nZone3 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
if ( !U_SUCCESS(status) )
- nZone2 = nZone1;
- sal_Int32 nDST2 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST2 = nDST1;
- if ( nZone0 != nZone1 || nZone2 != nZone1 || nDST0 != nDST1 || nDST2 != nDST1 )
+ nZone3 = nZone2;
+ if (nZone3 != nZone2)
{
- // Due to different DSTs, resulting date values may differ if
- // DST is onset at 00:00 and the very onsetRule date was
- // submitted with DST off => date-1 23:00, for example, which
- // is not what we want.
- // Resubmit all values, this time including DST => date 01:00
- // Similar for zone differences.
- // If already the first full submission with nZone0 and nDST0
- // lead to date-1 23:00, the original submission was based on
- // that date if it wasn't a full date (nDST0 set, nDST1 not
- // set, nDST2==nDST1). If it was January 1st without year we're
- // even off by one year now. Resubmit all values including new
- // DST => date 00:00.
-
- // Set field values accordingly in case they were used.
+ bResubmit = true;
if (!bNeedZone)
- lcl_setCombinedOffsetFieldValues( nZone2, fieldSetValue,
+ lcl_setCombinedOffsetFieldValues( nZone3, fieldSetValue,
fieldValue, CalendarFieldIndex::ZONE_OFFSET,
CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
- if (!bNeedDST)
- lcl_setCombinedOffsetFieldValues( nDST2, fieldSetValue,
- fieldValue, CalendarFieldIndex::DST_OFFSET,
- CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone2, nDST2);
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch resubmit"));
-
- // Time zone transition => resubmit.
- // TZ=America/St_Johns date <= 1935-03-30
- // -3:30:52 (!) instead of -3:30
- // if first submission included time zone -3:30 that would be wrong.
- bool bResubmit = false;
- sal_Int32 nZone3 = body->get( UCAL_ZONE_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nZone3 = nZone2;
- if (nZone3 != nZone2)
- {
- bResubmit = true;
- if (!bNeedZone)
- lcl_setCombinedOffsetFieldValues( nZone3, fieldSetValue,
- fieldValue, CalendarFieldIndex::ZONE_OFFSET,
- CalendarFieldIndex::ZONE_OFFSET_SECOND_MILLIS);
- }
+ }
- // If the DST onset rule says to switch from 00:00 to 01:00 and
- // we tried to set onsetDay 00:00 with DST, the result was
- // onsetDay-1 23:00 and no DST, which is not what we want. So
- // once again without DST, resulting in onsetDay 01:00 and DST.
- // Yes, this seems to be weird, but logically correct.
- // It doesn't even have to be on an onsetDay as the DST is
- // factored in all days by ICU and there seems to be some
- // unknown behavior.
- // TZ=Asia/Tehran 1999-03-22 exposes this, for example.
- sal_Int32 nDST3 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) )
- nDST3 = nDST2;
- if (nDST2 != nDST3 && !nDST3)
- {
- bResubmit = true;
- if (!bNeedDST)
- {
- fieldSetValue[CalendarFieldIndex::DST_OFFSET] =
- fieldValue[CalendarFieldIndex::DST_OFFSET] = 0;
- fieldSetValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] =
- fieldValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] = 0;
- }
- }
- if (bResubmit)
+ // If the DST onset rule says to switch from 00:00 to 01:00 and
+ // we tried to set onsetDay 00:00 with DST, the result was
+ // onsetDay-1 23:00 and no DST, which is not what we want. So
+ // once again without DST, resulting in onsetDay 01:00 and DST.
+ // Yes, this seems to be weird, but logically correct.
+ // It doesn't even have to be on an onsetDay as the DST is
+ // factored in all days by ICU and there seems to be some
+ // unknown behavior.
+ // TZ=Asia/Tehran 1999-03-22 exposes this, for example.
+ sal_Int32 nDST3 = body->get( UCAL_DST_OFFSET, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nDST3 = nDST2;
+ if (nDST2 != nDST3 && !nDST3)
+ {
+ bResubmit = true;
+ if (!bNeedDST)
{
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone3, nDST3);
- DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
- DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ fieldSetValue[CalendarFieldIndex::DST_OFFSET] =
+ fieldValue[CalendarFieldIndex::DST_OFFSET] = 0;
+ fieldSetValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] =
+ fieldValue[CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS] = 0;
}
- SAL_INFO( "i18npool", "Calendar_gregorian::setValue:" <<
- " nZone0 " << nZone0 << ", nDST0 " << nDST0 <<
- ", nZone1 " << nZone1 << ", nDST1 " << nDST1 <<
- ", nZone2 " << nZone2 << ", nDST2 " << nDST2 <<
- ", nZone3 " << nZone3 << ", nDST3 " << nDST3);
}
+ if (bResubmit)
+ {
+ submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone3, nDST3);
+ DUMP_ICU_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ DUMP_I18N_CAL_MSG(("%s\n","setValue() after Zone/DST glitch 2nd resubmit"));
+ }
+ SAL_INFO( "i18npool", "Calendar_gregorian::setValue:" <<
+ " nZone0 " << nZone0 << ", nDST0 " << nDST0 <<
+ ", nZone1 " << nZone1 << ", nDST1 " << nDST1 <<
+ ", nZone2 " << nZone2 << ", nDST2 " << nDST2 <<
+ ", nZone3 " << nZone3 << ", nDST3 " << nDST3);
}
+ }
#if erDUMP_ICU_CALENDAR || erDUMP_I18N_CALENDAR
- {
- // force icu::Calendar to recalculate
- UErrorCode status;
- sal_Int32 nTmp = body->get( UCAL_DATE, status = U_ZERO_ERROR);
- DUMP_ICU_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
- DUMP_I18N_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
- }
+ {
+ // force icu::Calendar to recalculate
+ UErrorCode status;
+ sal_Int32 nTmp = body->get( UCAL_DATE, status = U_ZERO_ERROR);
+ DUMP_ICU_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
+ DUMP_I18N_CAL_MSG(("%s: %d\n","setValue() result day",nTmp));
+ }
#endif
}
@@ -768,30 +768,30 @@ Calendar_gregorian::getValue( sal_Int16 fieldIndex ) throw(RuntimeException)
void SAL_CALL
Calendar_gregorian::addValue( sal_Int16 fieldIndex, sal_Int32 value ) throw(RuntimeException)
{
- // since ZONE and DST could not be add, we don't need to convert value here
- UErrorCode status;
- body->add(fieldNameConverter(fieldIndex), value, status = U_ZERO_ERROR);
- if ( !U_SUCCESS(status) ) throw ERROR;
- getValue();
+ // since ZONE and DST could not be add, we don't need to convert value here
+ UErrorCode status;
+ body->add(fieldNameConverter(fieldIndex), value, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) ) throw ERROR;
+ getValue();
}
sal_Bool SAL_CALL
Calendar_gregorian::isValid() throw(RuntimeException)
{
- if (fieldSet) {
- sal_Int32 tmp = fieldSet;
- setValue();
- memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
- getValue();
- for ( sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++ ) {
- // compare only with fields that are set and reset fieldSet[]
- if (tmp & (1 << fieldIndex)) {
- if (fieldSetValue[fieldIndex] != fieldValue[fieldIndex])
- return sal_False;
- }
+ if (fieldSet) {
+ sal_Int32 tmp = fieldSet;
+ setValue();
+ memcpy(fieldSetValue, fieldValue, sizeof(fieldSetValue));
+ getValue();
+ for ( sal_Int16 fieldIndex = 0; fieldIndex < FIELD_INDEX_COUNT; fieldIndex++ ) {
+ // compare only with fields that are set and reset fieldSet[]
+ if (tmp & (1 << fieldIndex)) {
+ if (fieldSetValue[fieldIndex] != fieldValue[fieldIndex])
+ return sal_False;
}
}
- return true;
+ }
+ return true;
}
// NativeNumberMode has different meaning between Number and Calendar for Asian locales.
@@ -894,123 +894,123 @@ throw(RuntimeException)
void SAL_CALL
Calendar_gregorian::setMinimumNumberOfDaysForFirstWeek( sal_Int16 days ) throw(RuntimeException)
{
- aCalendar.MinimumNumberOfDaysForFirstWeek = days;
- body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
+ aCalendar.MinimumNumberOfDaysForFirstWeek = days;
+ body->setMinimalDaysInFirstWeek( static_cast<uint8_t>( days));
}
sal_Int16 SAL_CALL
Calendar_gregorian::getMinimumNumberOfDaysForFirstWeek() throw(RuntimeException)
{
- return aCalendar.MinimumNumberOfDaysForFirstWeek;
+ return aCalendar.MinimumNumberOfDaysForFirstWeek;
}
sal_Int16 SAL_CALL
Calendar_gregorian::getNumberOfMonthsInYear() throw(RuntimeException)
{
- return (sal_Int16) aCalendar.Months.getLength();
+ return (sal_Int16) aCalendar.Months.getLength();
}
sal_Int16 SAL_CALL
Calendar_gregorian::getNumberOfDaysInWeek() throw(RuntimeException)
{
- return (sal_Int16) aCalendar.Days.getLength();
+ return (sal_Int16) aCalendar.Days.getLength();
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getDays() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendarItems( aCalendar.Days);
+ return LocaleDataImpl::downcastCalendarItems( aCalendar.Days);
}
Sequence< CalendarItem > SAL_CALL
Calendar_gregorian::getMonths() throw(RuntimeException)
{
- return LocaleDataImpl::downcastCalendarItems( aCalendar.Months);
+ return LocaleDataImpl::downcastCalendarItems( aCalendar.Months);
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getDays2() throw(RuntimeException)
{
- return aCalendar.Days;
+ return aCalendar.Days;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getMonths2() throw(RuntimeException)
{
- return aCalendar.Months;
+ return aCalendar.Months;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getGenitiveMonths2() throw(RuntimeException)
{
- return aCalendar.GenitiveMonths;
+ return aCalendar.GenitiveMonths;
}
Sequence< CalendarItem2 > SAL_CALL
Calendar_gregorian::getPartitiveMonths2() throw(RuntimeException)
{
- return aCalendar.PartitiveMonths;
+ return aCalendar.PartitiveMonths;
}
OUString SAL_CALL
Calendar_gregorian::getDisplayName( sal_Int16 displayIndex, sal_Int16 idx, sal_Int16 nameType ) throw(RuntimeException)
{
- OUString aStr;
+ OUString aStr;
- switch( displayIndex ) {
- case CalendarDisplayIndex::AM_PM:/* ==0 */
- if (idx == 0) aStr = LocaleDataImpl().getLocaleItem(aLocale).timeAM;
- else if (idx == 1) aStr = LocaleDataImpl().getLocaleItem(aLocale).timePM;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::DAY:
- if( idx >= aCalendar.Days.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::MONTH:
- if( idx >= aCalendar.Months.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::GENITIVE_MONTH:
- if( idx >= aCalendar.GenitiveMonths.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::PARTITIVE_MONTH:
- if( idx >= aCalendar.PartitiveMonths.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
- else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::ERA:
- if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
- if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
- else if (nameType == 1) aStr = aCalendar.Eras[idx].FullName;
- else throw ERROR;
- break;
- case CalendarDisplayIndex::YEAR:
- break;
- default:
- throw ERROR;
- }
- return aStr;
+ switch( displayIndex ) {
+ case CalendarDisplayIndex::AM_PM:/* ==0 */
+ if (idx == 0) aStr = LocaleDataImpl().getLocaleItem(aLocale).timeAM;
+ else if (idx == 1) aStr = LocaleDataImpl().getLocaleItem(aLocale).timePM;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::DAY:
+ if( idx >= aCalendar.Days.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Days[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Days[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Days[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::MONTH:
+ if( idx >= aCalendar.Months.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Months[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Months[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.Months[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::GENITIVE_MONTH:
+ if( idx >= aCalendar.GenitiveMonths.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.GenitiveMonths[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.GenitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.GenitiveMonths[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::PARTITIVE_MONTH:
+ if( idx >= aCalendar.PartitiveMonths.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.PartitiveMonths[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.PartitiveMonths[idx].FullName;
+ else if (nameType == 2) aStr = aCalendar.PartitiveMonths[idx].NarrowName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::ERA:
+ if( idx >= aCalendar.Eras.getLength() ) throw ERROR;
+ if (nameType == 0) aStr = aCalendar.Eras[idx].AbbrevName;
+ else if (nameType == 1) aStr = aCalendar.Eras[idx].FullName;
+ else throw ERROR;
+ break;
+ case CalendarDisplayIndex::YEAR:
+ break;
+ default:
+ throw ERROR;
+ }
+ return aStr;
}
// Methods in XExtendedCalendar
@@ -1168,21 +1168,21 @@ Calendar_buddhist::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 n
OUString SAL_CALL
Calendar_gregorian::getImplementationName(void) throw( RuntimeException )
{
- return OUString::createFromAscii(cCalendar);
+ return OUString::createFromAscii(cCalendar);
}
sal_Bool SAL_CALL
Calendar_gregorian::supportsService(const OUString& rServiceName) throw( RuntimeException )
{
- return !rServiceName.compareToAscii(cCalendar);
+ return !rServiceName.compareToAscii(cCalendar);
}
Sequence< OUString > SAL_CALL
Calendar_gregorian::getSupportedServiceNames(void) throw( RuntimeException )
{
- Sequence< OUString > aRet(1);
- aRet[0] = OUString::createFromAscii(cCalendar);
- return aRet;
+ Sequence< OUString > aRet(1);
+ aRet[0] = OUString::createFromAscii(cCalendar);
+ return aRet;
}
}}}}