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 /svtools | |
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 'svtools')
-rw-r--r-- | svtools/source/control/calendar.cxx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index 575463bd3912..b89b9061fde0 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -453,8 +453,8 @@ void Calendar::ImplFormat() } // get DateInfo - sal_uInt16 nNewFirstYear = maFirstDate.GetYear(); - sal_uInt16 nNewLastYear = GetLastDate().GetYear(); + sal_Int16 nNewFirstYear = maFirstDate.GetYear(); + sal_Int16 nNewLastYear = GetLastDate().GetYear(); if ( mnFirstYear ) { if ( nNewFirstYear < mnFirstYear ) @@ -670,9 +670,9 @@ void Calendar::ImplDrawSpin(vcl::RenderContext& rRenderContext ) void Calendar::ImplDrawDate(vcl::RenderContext& rRenderContext, long nX, long nY, - sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear, + sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear, DayOfWeek eDayOfWeek, - bool bOther, sal_uLong nToday ) + bool bOther, sal_Int32 nToday ) { Color* pTextColor = nullptr; const OUString& rDay = maDayTexts[nDay - 1]; @@ -769,10 +769,10 @@ void Calendar::ImplDraw(vcl::RenderContext& rRenderContext) long nDeltaY; long nDayX; long nDayY; - sal_uLong nToday = Date(Date::SYSTEM).GetDate(); + sal_Int32 nToday = Date(Date::SYSTEM).GetDate(); sal_uInt16 nDay; sal_uInt16 nMonth; - sal_uInt16 nYear; + sal_Int16 nYear; Date aDate = GetFirstMonth(); DayOfWeek eStartDay = ImplGetWeekStart(); @@ -1559,7 +1559,7 @@ void Calendar::RequestHelp( const HelpEvent& rHEvt ) if ( (nMonth == 12) && (nWeek == 1) ) { aStr += ", "; - aStr += OUString::number(aDate.GetYear()+1); + aStr += OUString::number(aDate.GetNextYear()); } else if ( (nMonth == 1) && (nWeek > 50) ) { @@ -1761,7 +1761,7 @@ Date Calendar::GetFirstMonth() const if ( maFirstDate.GetDay() > 1 ) { if ( maFirstDate.GetMonth() == 12 ) - return Date( 1, 1, maFirstDate.GetYear()+1 ); + return Date( 1, 1, maFirstDate.GetNextYear() ); else return Date( 1, maFirstDate.GetMonth()+1, maFirstDate.GetYear() ); } @@ -2155,7 +2155,7 @@ CalendarField::CalendarField(vcl::Window* pParent, WinBits nWinStyle) , mnCalendarStyle(0) , mpTodayBtn(nullptr) , mpNoneBtn(nullptr) - , maDefaultDate( 0, 0, 0 ) + , maDefaultDate( Date::EMPTY ) , mbToday(false) , mbNone(false) { |