diff options
author | Karl Hong <khong@openoffice.org> | 2002-10-22 02:44:25 +0000 |
---|---|---|
committer | Karl Hong <khong@openoffice.org> | 2002-10-22 02:44:25 +0000 |
commit | a5c7331baef504bd6133d8c91394392e275624d4 (patch) | |
tree | c7c9fcaaf687b4a50d1be372fb86c94ceb7f3c53 /i18npool | |
parent | 5c9b384f6b205ba0d9563b8c5c17bb682182000d (diff) |
#104354# Fix year format for the Year less than 100
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/calendar/calendar_gregorian.cxx | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx index 4d02be694312..c150d188483a 100644 --- a/i18npool/source/calendar/calendar_gregorian.cxx +++ b/i18npool/source/calendar/calendar_gregorian.cxx @@ -2,9 +2,9 @@ * * $RCSfile: calendar_gregorian.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: khong $ $Date: 2002-10-10 18:22:21 $ + * last change: $Author: khong $ $Date: 2002-10-22 03:44:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -335,10 +335,10 @@ Calendar_gregorian::isValid() throw(RuntimeException) // NatNum4 NatNum9/9/11/11 static sal_Int16 SAL_CALL NatNumForCalendar(const com::sun::star::lang::Locale& aLocale, - sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) + sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode, sal_Int16 value ) { - sal_Bool isShort = nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR || - nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR || + sal_Bool isShort = (nCalendarDisplayCode == CalendarDisplayCode::SHORT_YEAR || + nCalendarDisplayCode == CalendarDisplayCode::LONG_YEAR) && value >= 100 || nCalendarDisplayCode == CalendarDisplayCode::SHORT_QUARTER || nCalendarDisplayCode == CalendarDisplayCode::LONG_QUARTER; sal_Bool isChinese = aLocale.Language.equalsAscii("zh"); @@ -424,20 +424,24 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 sal_Char aStr[10]; switch( nCalendarDisplayCode ) { case CalendarDisplayCode::SHORT_MONTH: - value += 1; // month is zero based - // fall thru - case CalendarDisplayCode::SHORT_DAY: - case CalendarDisplayCode::LONG_YEAR: - sprintf(aStr, "%d", value); + // month is zero based + sprintf(aStr, "%d", value + 1); break; case CalendarDisplayCode::LONG_MONTH: - value += 1; // month is zero based - sprintf(aStr, "%02d", value); + // month is zero based + sprintf(aStr, "%02d", value + 1); break; case CalendarDisplayCode::SHORT_YEAR: - // take last 2 digits - value %= 100; - // fall through + if (value >= 100) + // take last 2 digits + sprintf(aStr, "%02d", value % 100); + else + sprintf(aStr, "%d", value); + break; + case CalendarDisplayCode::SHORT_DAY: + sprintf(aStr, "%d", value); + break; + case CalendarDisplayCode::LONG_YEAR: case CalendarDisplayCode::LONG_DAY: sprintf(aStr, "%02d", value); break; @@ -469,7 +473,7 @@ Calendar_gregorian::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 aOUStr = OUString::createFromAscii(aStr); } if (nNativeNumberMode > 0) { - sal_Int16 nNatNum = NatNumForCalendar(aLocale, nCalendarDisplayCode, nNativeNumberMode); + sal_Int16 nNatNum = NatNumForCalendar(aLocale, nCalendarDisplayCode, nNativeNumberMode, value); if (nNatNum > 0) return aNatNum.getNativeNumberString(aOUStr, aLocale, nNatNum); } |