From c3302e7e295593f89b6e355c921c9e16d8826d0f Mon Sep 17 00:00:00 2001 From: Ron Lee Date: Mon, 21 May 2001 19:03:33 +0000 Subject: [PATCH] Default wxDateTime objects are now 'invalid', changed wxDefaultDateTime definition to suit. Removed IsValid asserts from Set methods. Fixed broken test for validity that was checking m_time directly. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10256 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/datetime.h | 5 ++--- src/common/datetime.cpp | 17 ++--------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 92398e53f2..14c36c2d25 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -539,7 +539,7 @@ public: // ------------------------------------------------------------------------ // default ctor does not initialize the object, use Set()! - wxDateTime() { } + wxDateTime() { m_time = wxLongLong((long)ULONG_MAX, ULONG_MAX); } // from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970) #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) @@ -773,8 +773,7 @@ public: // result of timezone shift) // ------------------------------------------------------------------------ - // is the date valid? Note that this will return TRUE for non - // initialized objects but FALSE if *this == wxInvalidDateTime + // is the date valid? inline bool IsValid() const { return m_time != wxInvalidDateTime.m_time; } // get the broken down date/time representation in the given timezone diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 987c812183..c04f928cee 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -194,11 +194,8 @@ static const wxDateTime::wxDateTime_t gs_cumulatedDays[2][MONTHS_IN_YEAR] = // in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to // indicate an invalid wxDateTime object -#ifdef __WIN16__ + static const wxDateTime gs_dtDefault; -#else -static const wxDateTime gs_dtDefault = wxLongLong((long)ULONG_MAX, ULONG_MAX); -#endif const wxDateTime& wxDefaultDateTime = gs_dtDefault; @@ -1071,8 +1068,6 @@ wxDateTime wxDateTime::GetEndDST(int year, Country country) // the values in the tm structure contain the local time wxDateTime& wxDateTime::Set(const struct tm& tm) { - wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); - struct tm tm2(tm); time_t timet = mktime(&tm2); @@ -1111,8 +1106,6 @@ wxDateTime& wxDateTime::Set(wxDateTime_t hour, wxDateTime_t second, wxDateTime_t millisec) { - wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); - // we allow seconds to be 61 to account for the leap seconds, even if we // don't use them really wxDATETIME_CHECK( hour < 24 && @@ -1145,8 +1138,6 @@ wxDateTime& wxDateTime::Set(wxDateTime_t day, wxDateTime_t second, wxDateTime_t millisec) { - wxASSERT_MSG( IsValid(), _T("invalid wxDateTime") ); - wxDATETIME_CHECK( hour < 24 && second < 62 && minute < 60 && @@ -2937,11 +2928,7 @@ const wxChar *wxDateTime::ParseFormat(const wxChar *date, // take this date as default tmDef = dateDef.GetTm(); } -#ifdef __WIN16__ - else if ( m_time != 0 ) -#else - else if ( m_time != wxLongLong(0) ) -#endif + else if ( IsValid() ) { // if this date is valid, don't change it tmDef = GetTm(); -- 2.45.2