diff options
-rw-r--r-- | chart2/source/view/axes/DateHelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/oleprops.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/dateitem.cxx | 2 | ||||
-rw-r--r-- | svtools/source/contnr/templwin.cxx | 2 | ||||
-rw-r--r-- | svtools/source/control/calendar.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/fields/docufld.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/docvw/SidebarWin.cxx | 2 | ||||
-rw-r--r-- | tools/inc/tools/date.hxx | 6 | ||||
-rw-r--r-- | tools/source/datetime/tdate.cxx | 2 | ||||
-rw-r--r-- | tools/source/inet/inetmsg.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/field2.cxx | 2 |
14 files changed, 22 insertions, 18 deletions
diff --git a/chart2/source/view/axes/DateHelper.cxx b/chart2/source/view/axes/DateHelper.cxx index 142dd6056cfb..6749e749171e 100644 --- a/chart2/source/view/axes/DateHelper.cxx +++ b/chart2/source/view/axes/DateHelper.cxx @@ -73,7 +73,7 @@ Date DateHelper::GetDateSomeMonthsAway( const Date& rD, long nMonthDistance ) nNewMonth += 12; aRet.SetMonth( sal_uInt16(nNewMonth) ); aRet.SetYear( sal_uInt16(nNewYear) ); - while(!aRet.IsValid()) + while(!aRet.IsValidAndGregorian()) aRet--; return aRet; } @@ -82,7 +82,7 @@ Date DateHelper::GetDateSomeYearsAway( const Date& rD, long nYearDistance ) { Date aRet(rD); aRet.SetYear( static_cast<sal_uInt16>(rD.GetYear()+nYearDistance) ); - while(!aRet.IsValid()) + while(!aRet.IsValidAndGregorian()) aRet--; return aRet; } diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index be38e1f4734a..ef422581ffb3 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -93,7 +93,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1 Date aDate( nD, nM, nY); if (!bStrict) aDate += nDay - 1; - if (aDate.IsValid()) + if (aDate.IsValidAndGregorian()) return (double) (aDate - *(pFormatter->GetNullDate())); else { diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 772a4283507a..625ecd40013f 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -175,7 +175,7 @@ OUString getAnnotationDateTimeString( const Reference< XAnnotation >& xAnnotatio if (aDate == Date(Date()-1)) sRet = sRet + String(SdResId(STR_ANNOTATION_YESTERDAY)); else - if (aDate.IsValid() ) + if (aDate.IsValidAndGregorian() ) sRet = sRet + rLocalData.getDate(aDate); Time aTime( aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.HundredthSeconds ); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index ab3cbfc3c5e6..097eba93135e 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -2969,7 +2969,7 @@ void SfxMedium::SetExpired_Impl( const DateTime& rDateTime ) sal_Bool SfxMedium::IsExpired() const { - return pImp->aExpireTime.IsValid() && pImp->aExpireTime < DateTime(); + return pImp->aExpireTime.IsValidAndGregorian() && pImp->aExpireTime < DateTime(); } //---------------------------------------------------------------- diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx index b7d56b0f1061..f42ed879124a 100644 --- a/sfx2/source/doc/oleprops.cxx +++ b/sfx2/source/doc/oleprops.cxx @@ -634,7 +634,7 @@ void SfxOleFileTimeProperty::ImplSave( SvStream& rStrm ) // invalid time stamp is not converted to UTC // heuristic to detect editing durations (which we assume to be < 1 year): // check only the year, not the entire date - if( aDateTimeUtc.IsValid() + if( aDateTimeUtc.IsValidAndGregorian() && aDateTimeUtc.GetYear() != TIMESTAMP_INVALID_DATETIME.GetYear() ) { aDateTimeUtc.ConvertToUTC(); } diff --git a/svl/source/items/dateitem.cxx b/svl/source/items/dateitem.cxx index 1df6b6250745..accd1cfb8ca3 100644 --- a/svl/source/items/dateitem.cxx +++ b/svl/source/items/dateitem.cxx @@ -148,7 +148,7 @@ SfxItemPresentation SfxDateTimeItem::GetPresentation ) const { DBG_CHKTHIS(SfxDateTimeItem, 0); - if (aDateTime.IsValid()) + if (aDateTime.IsValidAndGregorian()) if (pIntlWrapper) { rText = pIntlWrapper->getLocaleData()->getDate(aDateTime); diff --git a/svtools/source/contnr/templwin.cxx b/svtools/source/contnr/templwin.cxx index 3792826ee571..c2daae824d1d 100644 --- a/svtools/source/contnr/templwin.cxx +++ b/svtools/source/contnr/templwin.cxx @@ -164,7 +164,7 @@ void lcl_insertDateTimeEntry(SvtExtendedMultiLineEdit_Impl* i_pEditWin, DateTime( Date( i_rUDT.Day, i_rUDT.Month, i_rUDT.Year ), Time( i_rUDT.Hours, i_rUDT.Minutes, i_rUDT.Seconds, i_rUDT.HundredthSeconds ) ); - if ( aToolsDT.IsValid() ) + if ( aToolsDT.IsValidAndGregorian() ) { LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx index 7b4bf577db6a..4ff76c3e23e2 100644 --- a/svtools/source/control/calendar.cxx +++ b/svtools/source/control/calendar.cxx @@ -1974,7 +1974,7 @@ void Calendar::Select() void Calendar::SelectDate( const Date& rDate, sal_Bool bSelect ) { - if ( !rDate.IsValid() ) + if ( !rDate.IsValidAndGregorian() ) return; Table* pOldSel; @@ -2037,7 +2037,7 @@ Date Calendar::GetSelectDate( sal_uLong nIndex ) const void Calendar::SetCurDate( const Date& rNewDate ) { - if ( !rNewDate.IsValid() ) + if ( !rNewDate.IsValidAndGregorian() ) return; if ( maCurDate != rNewDate ) @@ -2638,9 +2638,9 @@ sal_Bool CalendarField::ShowDropDown( sal_Bool bShow ) Calendar* pCalendar = GetCalendar(); Date aDate = GetDate(); - if ( IsEmptyDate() || !aDate.IsValid() ) + if ( IsEmptyDate() || !aDate.IsValidAndGregorian() ) { - if ( maDefaultDate.IsValid() ) + if ( maDefaultDate.IsValidAndGregorian() ) aDate = maDefaultDate; else aDate = Date(); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index f950016b06ca..74366eaf9b2d 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -994,7 +994,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, else break; - if (aDate.IsValid()) + if (aDate.IsValidAndGregorian()) { switch (nExtSub & ~DI_SUB_FIXED) { diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx index fe2b53c84543..311e5bdd1dab 100644 --- a/sw/source/ui/docvw/SidebarWin.cxx +++ b/sw/source/ui/docvw/SidebarWin.cxx @@ -415,7 +415,7 @@ void SwSidebarWin::CheckMetaText() { sMeta = String(SW_RES(STR_POSTIT_YESTERDAY)); } - else if (aDate.IsValid() ) + else if (aDate.IsValidAndGregorian() ) { sMeta = rLocalData.getDate(aDate); } diff --git a/tools/inc/tools/date.hxx b/tools/inc/tools/date.hxx index 183f6af43fbd..a9d0e0d53848 100644 --- a/tools/inc/tools/date.hxx +++ b/tools/inc/tools/date.hxx @@ -80,7 +80,11 @@ public: sal_uInt16 GetDaysInMonth() const; sal_uInt16 GetDaysInYear() const { return (IsLeapYear()) ? 366 : 365; } sal_Bool IsLeapYear() const; - sal_Bool IsValid() const; + /** If the represented date is valid (1<=month<=12, 1<=day<=(28,29,30,31) + depending on month/year) AND is of the Gregorian calendar (1582-10-15 + <= date) (AND implicitly date <= 9999-12-31 due to internal + representation) */ + sal_Bool IsValidAndGregorian() const; sal_Bool IsBetween( const Date& rFrom, const Date& rTo ) const { return ((nDate >= rFrom.nDate) && diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx index 47af8c049110..06b0bc4d1346 100644 --- a/tools/source/datetime/tdate.cxx +++ b/tools/source/datetime/tdate.cxx @@ -318,7 +318,7 @@ sal_Bool Date::IsLeapYear() const // ----------------------------------------------------------------------- -sal_Bool Date::IsValid() const +sal_Bool Date::IsValidAndGregorian() const { sal_uInt16 nDay = GetDay(); sal_uInt16 nMonth = GetMonth(); diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx index 42ab896b2b00..e0db5949e08e 100644 --- a/tools/source/inet/inetmsg.cxx +++ b/tools/source/inet/inetmsg.cxx @@ -431,7 +431,7 @@ sal_Bool INetRFC822Message::ParseDateField ( return sal_False; } - return (rDateTime.IsValid() && + return (rDateTime.IsValidAndGregorian() && !((rDateTime.GetSec() > 59) || (rDateTime.GetMin() > 59) || (rDateTime.GetHour() > 23) )); diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx index 31e94037304d..5fadf7ec49a6 100644 --- a/vcl/source/control/field2.cxx +++ b/vcl/source/control/field2.cxx @@ -1309,7 +1309,7 @@ static sal_Bool ImplDateGetValue( const XubString& rStr, Date& rDate, ExtDateFie Date aNewDate( nDay, nMonth, nYear ); DateFormatter::ExpandCentury( aNewDate, utl::MiscCfg().GetYear2000() ); - if ( aNewDate.IsValid() ) + if ( aNewDate.IsValidAndGregorian() ) { rDate = aNewDate; return sal_True; |