summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-30 02:05:22 +0100
committerEike Rathke <erack@redhat.com>2011-11-30 02:05:22 +0100
commitdca69d5bb2d0e542de26624dd9f71fb87e1533f2 (patch)
treed3d6b62417885946113b6f13e10ca0f4fc45613c /tools
parentcb937da55c3ab3d238b97d6e0e709ea2a04d2c26 (diff)
renamed Date::IsValid() to IsValidAndGregorian() to prevent misassumptions
Once smaller than 1582-10-15 decrementing a Date will not produce a valid date.
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/date.hxx6
-rw-r--r--tools/source/datetime/tdate.cxx2
-rw-r--r--tools/source/inet/inetmsg.cxx2
3 files changed, 7 insertions, 3 deletions
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) ));