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 /chart2 | |
parent | Resolves: rhbz#1352881 turn off undo generation during undo (diff) | |
download | core-6d4f2dcc7cbba771e9d9b00de50368db4a88ef1b.tar.gz core-6d4f2dcc7cbba771e9d9b00de50368db4a88ef1b.zip |
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 'chart2')
-rw-r--r-- | chart2/source/tools/NumberFormatterWrapper.cxx | 3 | ||||
-rw-r--r-- | chart2/source/view/axes/DateHelper.cxx | 18 | ||||
-rw-r--r-- | chart2/source/view/inc/DateHelper.hxx | 4 |
3 files changed, 8 insertions, 17 deletions
diff --git a/chart2/source/tools/NumberFormatterWrapper.cxx b/chart2/source/tools/NumberFormatterWrapper.cxx index 52c6a5250a55..1151aa4aeaab 100644 --- a/chart2/source/tools/NumberFormatterWrapper.cxx +++ b/chart2/source/tools/NumberFormatterWrapper.cxx @@ -98,7 +98,8 @@ OUString NumberFormatterWrapper::getFormattedString( sal_Int32 nNumberFormatKey, return aText; } // i99104 handle null date correctly - sal_uInt16 nYear = 1899,nDay = 30,nMonth = 12; + sal_Int16 nYear = 1899; + sal_uInt16 nDay = 30,nMonth = 12; if ( m_aNullDate.hasValue() ) { Date* pDate = m_pNumberFormatter->GetNullDate(); diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx index d8c872711c51..42a77cd045ec 100644 --- a/chart2/source/view/axes/DateHelper.cxx +++ b/chart2/source/view/axes/DateHelper.cxx @@ -37,27 +37,17 @@ bool DateHelper::IsInSameMonth( const Date& rD1, const Date& rD2 ) && (rD1.GetMonth() == rD2.GetMonth()); } -Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) +Date DateHelper::GetDateSomeMonthsAway( const Date& rD, sal_Int32 nMonthDistance ) { Date aRet(rD); - long nMonth = rD.GetMonth()+nMonthDistance; - long nNewMonth = nMonth%12; - long nNewYear = rD.GetYear() + nMonth/12; - if( nMonth <= 0 || !nNewMonth ) - nNewYear--; - if( nNewMonth <= 0 ) - nNewMonth += 12; - aRet.SetMonth( sal_uInt16(nNewMonth) ); - aRet.SetYear( sal_uInt16(nNewYear) ); - aRet.Normalize(); + aRet.AddMonths( nMonthDistance ); return aRet; } -Date DateHelper::GetDateSomeYearsAway( const Date& rD, long nYearDistance ) +Date DateHelper::GetDateSomeYearsAway( const Date& rD, sal_Int32 nYearDistance ) { Date aRet(rD); - aRet.SetYear( static_cast<sal_uInt16>(rD.GetYear()+nYearDistance) ); - aRet.Normalize(); + aRet.AddYears( static_cast<sal_Int16>(nYearDistance) ); return aRet; } diff --git a/chart2/source/view/inc/DateHelper.hxx b/chart2/source/view/inc/DateHelper.hxx index 3142e90c9f1d..099985533853 100644 --- a/chart2/source/view/inc/DateHelper.hxx +++ b/chart2/source/view/inc/DateHelper.hxx @@ -31,8 +31,8 @@ public: static bool IsInSameYear( const Date& rD1, const Date& rD2 ); static bool IsInSameMonth( const Date& rD1, const Date& rD2 ); - static Date GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ); - static Date GetDateSomeYearsAway( const Date& rD, long nYearDistance ); + static Date GetDateSomeMonthsAway( const Date& rD, sal_Int32 nMonthDistance ); + static Date GetDateSomeYearsAway( const Date& rD, sal_Int32 nYearDistance ); static bool IsLessThanOneMonthAway( const Date& rD1, const Date& rD2 ); static bool IsLessThanOneYearAway( const Date& rD1, const Date& rD2 ); |