// wxInvalidDateTime)
class WXDLLIMPEXP_FWD_BASE wxDateTime;
-extern WXDLLIMPEXP_DATA_BASE(const char *) wxDefaultDateTimeFormat;
-extern WXDLLIMPEXP_DATA_BASE(const char *) wxDefaultTimeSpanFormat;
+extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultDateTimeFormat[];
+extern WXDLLIMPEXP_DATA_BASE(const char) wxDefaultTimeSpanFormat[];
extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
#define wxInvalidDateTime wxDefaultDateTime
// conditional compilation
// ----------------------------------------------------------------------------
-// everyone has strftime except Win CE unless VC8 is used
-#if !defined(__WXWINCE__) || defined(__VISUALC8__)
- #define HAVE_STRFTIME
+// if configure detected strftime(), we have it too
+#ifdef HAVE_STRFTIME
+ #define wxHAS_STRFTIME
+// suppose everyone else has strftime except Win CE unless VC8 is used
+#elif !defined(__WXWINCE__) || defined(__VISUALC8__)
+ #define wxHAS_STRFTIME
#endif
// ----------------------------------------------------------------------------
// adoption of the Gregorian calendar (see IsGregorian())
//
// All data and comments taken verbatim from "The Calendar FAQ (v 2.0)"
- // by Claus T�ndering, http://www.pip.dknet.dk/~c-t/calendar.html
+ // by Claus Tøndering, http://www.pip.dknet.dk/~c-t/calendar.html
// except for the comments "we take".
//
// Symbol "->" should be read as "was followed by" in the comments
// instead of modifying the member fields directly!
struct WXDLLIMPEXP_BASE Tm
{
- wxDateTime_t msec, sec, min, hour, mday;
+ wxDateTime_t msec, sec, min, hour,
+ mday, // Day of the month in 1..31 range.
+ yday; // Day of the year in 0..365 range.
Month mon;
int year;
// the timezone we correspond to
TimeZone m_tz;
- // these values can't be accessed directly because they're not always
- // computed and we calculate them on demand
- wxDateTime_t wday, yday;
+ // This value can only be accessed via GetWeekDay() and not directly
+ // because it's not always computed when creating this object and may
+ // need to be calculated on demand.
+ wxDateTime_t wday;
};
// static methods
// SYSTEMTIME format
// ------------------------------------------------------------------------
#ifdef __WXMSW__
-
// convert SYSTEMTIME to wxDateTime
- wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME&);
+ wxDateTime& SetFromMSWSysTime(const struct _SYSTEMTIME& st);
// convert wxDateTime to SYSTEMTIME
- void GetAsMSWSysTime(struct _SYSTEMTIME*) const;
+ void GetAsMSWSysTime(struct _SYSTEMTIME* st) const;
+
+ // same as above but only take date part into account, time is always zero
+ wxDateTime& SetFromMSWSysDate(const struct _SYSTEMTIME& st);
+ void GetAsMSWSysDate(struct _SYSTEMTIME* st) const;
#endif // __WXMSW__
// comparison (see also functions below for operator versions)
inline bool operator<(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() < dt.GetValue();
}
inline bool operator<=(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() <= dt.GetValue();
}
inline bool operator>(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() > dt.GetValue();
}
inline bool operator>=(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() >= dt.GetValue();
}
inline bool operator==(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() == dt.GetValue();
}
inline bool operator!=(const wxDateTime& dt) const
{
- wxASSERT_MSG( IsValid() && dt.IsValid(), _T("invalid wxDateTime") );
+ wxASSERT_MSG( IsValid() && dt.IsValid(), wxT("invalid wxDateTime") );
return GetValue() != dt.GetValue();
}
inline bool wxDateTime::IsInStdRange() const
{
- return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX;
+ // currently we don't know what is the real type of time_t so prefer to err
+ // on the safe side and limit it to 32 bit values which is safe everywhere
+ return m_time >= 0l && (m_time / TIME_T_FACTOR) < wxINT32_MAX;
}
/* static */
inline wxDateTime& wxDateTime::Set(const Tm& tm)
{
- wxASSERT_MSG( tm.IsValid(), _T("invalid broken down date/time") );
+ wxASSERT_MSG( tm.IsValid(), wxT("invalid broken down date/time") );
return Set(tm.mday, (Month)tm.mon, tm.year,
tm.hour, tm.min, tm.sec, tm.msec);
inline wxLongLong wxDateTime::GetValue() const
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
return m_time;
}
inline time_t wxDateTime::GetTicks() const
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
if ( !IsInStdRange() )
{
return (time_t)-1;
inline bool wxDateTime::IsEqualTo(const wxDateTime& datetime) const
{
- wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), wxT("invalid wxDateTime"));
return m_time == datetime.m_time;
}
inline bool wxDateTime::IsEarlierThan(const wxDateTime& datetime) const
{
- wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), wxT("invalid wxDateTime"));
return m_time < datetime.m_time;
}
inline bool wxDateTime::IsLaterThan(const wxDateTime& datetime) const
{
- wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), wxT("invalid wxDateTime"));
return m_time > datetime.m_time;
}
inline wxDateTime wxDateTime::Add(const wxTimeSpan& diff) const
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
return wxDateTime(m_time + diff.GetValue());
}
inline wxDateTime& wxDateTime::Add(const wxTimeSpan& diff)
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
m_time += diff.GetValue();
inline wxDateTime wxDateTime::Subtract(const wxTimeSpan& diff) const
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
return wxDateTime(m_time - diff.GetValue());
}
inline wxDateTime& wxDateTime::Subtract(const wxTimeSpan& diff)
{
- wxASSERT_MSG( IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid(), wxT("invalid wxDateTime"));
m_time -= diff.GetValue();
inline wxTimeSpan wxDateTime::Subtract(const wxDateTime& datetime) const
{
- wxASSERT_MSG( IsValid() && datetime.IsValid(), _T("invalid wxDateTime"));
+ wxASSERT_MSG( IsValid() && datetime.IsValid(), wxT("invalid wxDateTime"));
return wxTimeSpan(GetValue() - datetime.GetValue());
}