#pragma hdrstop
#endif
+#if !defined(wxUSE_DATETIME) || wxUSE_DATETIME
+
#ifndef WX_PRECOMP
#include "wx/string.h"
- #include "wx/intl.h"
#include "wx/log.h"
#endif // WX_PRECOMP
+#include "wx/intl.h"
#include "wx/thread.h"
#include "wx/tokenzr.h"
#include "wx/module.h"
#define WX_TIMEZONE _timezone
#elif defined(__MWERKS__)
long wxmw_timezone = 28800;
- #define WX_TIMEZONE wxmw_timezone;
+ #define WX_TIMEZONE wxmw_timezone
+ #elif defined(__DJGPP__)
+ #include <sys/timeb.h>
+ #include <values.h>
+ static long wxGetTimeZone()
+ {
+ static long timezone = MAXLONG; // invalid timezone
+ if (timezone == MAXLONG)
+ {
+ struct timeb tb;
+ ftime(&tb);
+ timezone = tb.timezone;
+ }
+ return timezone;
+ }
+ #define WX_TIMEZONE wxGetTimeZone()
#else // unknown platform - try timezone
#define WX_TIMEZONE timezone
#endif
// in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to
// indicate an invalid wxDateTime object
-
-static const wxDateTime gs_dtDefault;
-
-const wxDateTime& wxDefaultDateTime = gs_dtDefault;
+const wxDateTime wxDefaultDateTime;
wxDateTime::Country wxDateTime::ms_country = wxDateTime::Country_Unknown;
// check that the algorithm gave us something reasonable
wxASSERT_MSG( (0 < month) && (month <= 12), _T("invalid month") );
wxASSERT_MSG( (1 <= day) && (day < 32), _T("invalid day") );
- wxASSERT_MSG( (INT_MIN <= year) && (year <= INT_MAX),
- _T("year range overflow") );
// construct Tm from these values
Tm tm;
}
}
- // try all time formats we may think about starting with the standard one
- const wxChar *result = ParseFormat(time, _T("%X"));
+ // try all time formats we may think about in the order from longest to
+ // shortest
+
+ // 12hour with AM/PM?
+ const wxChar *result = ParseFormat(time, _T("%I:%M:%S %p"));
+
if ( !result )
{
// normally, it's the same, but why not try it?
if ( !result )
{
- // 12hour with AM/PM?
- result = ParseFormat(time, _T("%I:%M:%S %p"));
+ // 12hour with AM/PM but without seconds?
+ result = ParseFormat(time, _T("%I:%M %p"));
}
if ( !result )
if ( !result )
{
- // 12hour with AM/PM but without seconds?
- result = ParseFormat(time, _T("%I:%M %p"));
+ // just the hour and AM/PM?
+ result = ParseFormat(time, _T("%I %p"));
}
if ( !result )
if ( !result )
{
- // just the hour and AM/PM?
- result = ParseFormat(time, _T("%I %p"));
+ // parse the standard format: normally it is one of the formats above
+ // but it may be set to something completely different by the user
+ result = ParseFormat(time, _T("%X"));
}
// TODO: parse timezones
// wxTimeSpan
// ============================================================================
+// this enum is only used in wxTimeSpan::Format() below but we can't declare
+// it locally to the method as it provokes an internal compiler error in egcs
+// 2.91.60 when building with -O2
+enum TimeSpanPart
+{
+ Part_Week,
+ Part_Day,
+ Part_Hour,
+ Part_Min,
+ Part_Sec,
+ Part_MSec
+};
+
// not all strftime(3) format specifiers make sense here because, for example,
// a time span doesn't have a year nor a timezone
//
// should use GetMinutes() % 60, otherwise just GetMinutes() &c
// we remember the most important unit found so far
- enum TimeSpanPart
- {
- Part_Week,
- Part_Day,
- Part_Hour,
- Part_Min,
- Part_Sec,
- Part_MSec
- } partBiggest = Part_MSec;
+ TimeSpanPart partBiggest = Part_MSec;
for ( const wxChar *pch = format; *pch; pch++ )
{
return holidays.GetCount();
}
-
+#endif // wxUSE_DATETIME