summaryrefslogtreecommitdiff
path: root/i18npool
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-07-08 17:08:47 +0200
committerEike Rathke <erack@redhat.com>2016-07-08 20:41:02 +0000
commit6d4f2dcc7cbba771e9d9b00de50368db4a88ef1b (patch)
tree0301896941b955ffa79ef3e96b874ebdad78662c /i18npool
parent06287b9c348281612854d67c4eb2e7a38dc722ca (diff)
Resolves: tdf#100452 class Date full (BCE,CE) proleptic Gregorian calendar
... implementing signed years with year 0 gap. Date(31,12,-1) last day BCE Date(1,1,1) first day CE New class Date member functions: * AddYears(sal_Int16) to be used instead of aDate.SetYear(aDate.GetYear()+sal_Int16) to handle year 0 gap. * convenience GetNextYear() to be used insted of GetYear()+1 * convenience GetPrevYear() to be used insted of GetYear()-1 * AddMonths(sal_Int32) * operator=(const css::util::Date&) New class DateTime member functions: * operator=(const css::util::DateTime&) Made some conversion ctors explicit, specifically Date(sal_Int32) Adapted hopefully all places that used a sal_uInt16 year to use sal_Int16 where appropriate. Eliminated some quirks in date handling found on the fly. Added era handling to i18npool icu calendar setting interface, which missing was responsible for 0001-01-01 entered in Calc being set as -0001-01-01, hence subtracting one day resulted in -0002-12-31. Change-Id: I77b39fba9599ebd5067d7864f6c9ebe01f6f578f Reviewed-on: https://gerrit.libreoffice.org/27049 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'i18npool')
-rw-r--r--i18npool/inc/calendar_gregorian.hxx4
-rw-r--r--i18npool/source/calendar/calendar_gregorian.cxx20
2 files changed, 16 insertions, 8 deletions
diff --git a/i18npool/inc/calendar_gregorian.hxx b/i18npool/inc/calendar_gregorian.hxx
index 4f333815a918..4a16c00c3eb6 100644
--- a/i18npool/inc/calendar_gregorian.hxx
+++ b/i18npool/inc/calendar_gregorian.hxx
@@ -116,9 +116,9 @@ private:
/** Submit fieldSetValue array according to fieldSet. */
void submitFields() throw(css::uno::RuntimeException);
- /** Submit fieldSetValue array according to fieldSet, plus YMDhms if >=0,
+ /** Submit fieldSetValue array according to fieldSet, plus EYMDhms if >=0,
plus zone and DST if != 0 */
- void submitValues( sal_Int32 nYear, sal_Int32 nMonth, sal_Int32 nDay, sal_Int32 nHour, sal_Int32 nMinute, sal_Int32 nSecond, sal_Int32 nMilliSecond, sal_Int32 nZone, sal_Int32 nDST) throw(css::uno::RuntimeException);
+ void submitValues( sal_Int32 nEra, sal_Int32 nYear, sal_Int32 nMonth, sal_Int32 nDay, sal_Int32 nHour, sal_Int32 nMinute, sal_Int32 nSecond, sal_Int32 nMilliSecond, sal_Int32 nZone, sal_Int32 nDST) throw(css::uno::RuntimeException);
/** Set fields internally. */
void setValue() throw(css::uno::RuntimeException);
/** Obtain combined field values for timezone offset (minutes+secondmillis)
diff --git a/i18npool/source/calendar/calendar_gregorian.cxx b/i18npool/source/calendar/calendar_gregorian.cxx
index fc470e109e8e..275b24dff0ed 100644
--- a/i18npool/source/calendar/calendar_gregorian.cxx
+++ b/i18npool/source/calendar/calendar_gregorian.cxx
@@ -491,12 +491,14 @@ void Calendar_gregorian::submitFields() throw(css::uno::RuntimeException)
body->set( fieldNameConverter( CalendarFieldIndex::DST_OFFSET), nDSTOffset);
}
-void Calendar_gregorian::submitValues( sal_Int32 nYear,
+void Calendar_gregorian::submitValues( sal_Int32 nEra, sal_Int32 nYear,
sal_Int32 nMonth, sal_Int32 nDay, sal_Int32 nHour, sal_Int32 nMinute,
sal_Int32 nSecond, sal_Int32 nMilliSecond, sal_Int32 nZone, sal_Int32 nDST )
throw(css::uno::RuntimeException)
{
submitFields();
+ if (nEra >= 0)
+ body->set( UCAL_ERA, nEra);
if (nYear >= 0)
body->set( UCAL_YEAR, nYear);
if (nMonth >= 0)
@@ -567,12 +569,18 @@ void Calendar_gregorian::setValue() throw(RuntimeException)
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;
+ sal_Int32 nZone1, nDST1, nEra, nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0;
nZone1 = nDST1 = nZone0 = nDST0 = 0;
- nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
+ nEra = nYear = nMonth = nDay = nHour = nMinute = nSecond = nMilliSecond = -1;
if ( bNeedZone || bNeedDST )
{
UErrorCode status;
+ if ( !(fieldSet & (1 << CalendarFieldIndex::ERA)) )
+ {
+ nEra = body->get( UCAL_ERA, status = U_ZERO_ERROR);
+ if ( !U_SUCCESS(status) )
+ nEra = -1;
+ }
if ( !(fieldSet & (1 << CalendarFieldIndex::YEAR)) )
{
nYear = body->get( UCAL_YEAR, status = U_ZERO_ERROR);
@@ -629,7 +637,7 @@ void Calendar_gregorian::setValue() throw(RuntimeException)
}
// Submit values to obtain a time zone and DST corresponding to the date/time.
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone0, nDST0);
+ submitValues( nEra, 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()"));
@@ -680,7 +688,7 @@ void Calendar_gregorian::setValue() throw(RuntimeException)
lcl_setCombinedOffsetFieldValues( nDST2, fieldSetValue,
fieldValue, CalendarFieldIndex::DST_OFFSET,
CalendarFieldIndex::DST_OFFSET_SECOND_MILLIS);
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone2, nDST2);
+ submitValues( nEra, 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"));
@@ -726,7 +734,7 @@ void Calendar_gregorian::setValue() throw(RuntimeException)
}
if (bResubmit)
{
- submitValues( nYear, nMonth, nDay, nHour, nMinute, nSecond, nMilliSecond, nZone3, nDST3);
+ submitValues( nEra, 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"));
}