diff options
author | Eike Rathke <erack@redhat.com> | 2016-07-08 17:08:47 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-07-08 20:41:02 +0000 |
commit | 6d4f2dcc7cbba771e9d9b00de50368db4a88ef1b (patch) | |
tree | 0301896941b955ffa79ef3e96b874ebdad78662c /xmloff/source | |
parent | 06287b9c348281612854d67c4eb2e7a38dc722ca (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 'xmloff/source')
-rw-r--r-- | xmloff/source/core/xmluconv.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/text/txtlists.cxx | 2 |
2 files changed, 15 insertions, 7 deletions
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 1f2fe2446f38..fa34a3006f6b 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -375,21 +375,29 @@ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, aDate += 1; } } - sal_uInt16 nTemp = aDate.GetYear(); - if (nTemp < 1000) + sal_Int16 nTempYear = aDate.GetYear(); + assert(nTempYear != 0); + if (nTempYear < 0) + { + rBuffer.append( '-'); + nTempYear = -nTempYear; + } + if (nTempYear < 1000) rBuffer.append( '0'); - if (nTemp < 100) + if (nTempYear < 100) rBuffer.append( '0'); - if (nTemp < 10) + if (nTempYear < 10) rBuffer.append( '0'); - rBuffer.append( sal_Int32( nTemp)); + rBuffer.append( sal_Int32( nTempYear)); rBuffer.append( '-'); - nTemp = aDate.GetMonth(); + sal_uInt16 nTemp = aDate.GetMonth(); + assert(1 <= nTemp && nTemp <= 12); if (nTemp < 10) rBuffer.append( '0'); rBuffer.append( sal_Int32( nTemp)); rBuffer.append( '-'); nTemp = aDate.GetDay(); + assert(1 <= nTemp && nTemp <= 31); if (nTemp < 10) rBuffer.append( '0'); rBuffer.append( sal_Int32( nTemp)); diff --git a/xmloff/source/text/txtlists.cxx b/xmloff/source/text/txtlists.cxx index 3fd31e514b4b..09c62c7f742c 100644 --- a/xmloff/source/text/txtlists.cxx +++ b/xmloff/source/text/txtlists.cxx @@ -225,7 +225,7 @@ OUString XMLTextListsHelper::GenerateNewListId() const { // Value of xml:id in element <text:list> has to be a valid ID type (#i92478#) sal_Int64 n = ::tools::Time( ::tools::Time::SYSTEM ).GetTime(); - n += Date( Date::SYSTEM ).GetDate(); + n += Date( Date::SYSTEM ).GetDateUnsigned(); n += comphelper::rng::uniform_int_distribution(0, std::numeric_limits<int>::max()); // Value of xml:id in element <text:list> has to be a valid ID type (#i92478#) sTmpStr += OUString::number( n ); |