#include "wx/longlong.h"
-class WXDLLIMPEXP_BASE wxDateTime;
-class WXDLLIMPEXP_BASE wxTimeSpan;
-class WXDLLIMPEXP_BASE wxDateSpan;
+class WXDLLIMPEXP_FWD_BASE wxDateTime;
+class WXDLLIMPEXP_FWD_BASE wxTimeSpan;
+class WXDLLIMPEXP_FWD_BASE wxDateSpan;
#include "wx/dynarray.h"
#ifdef HAVE_LOCALTIME_R
#define wxLocaltime_r localtime_r
#else
-struct tm *wxLocaltime_r(const time_t*, struct tm*);
+WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*);
#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
// On Windows, localtime _is_ threadsafe!
#warning using pseudo thread-safe wrapper for localtime to emulate localtime_r
#ifdef HAVE_GMTIME_R
#define wxGmtime_r gmtime_r
#else
-struct tm *wxGmtime_r(const time_t*, struct tm*);
+WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*);
#if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
// On Windows, gmtime _is_ threadsafe!
#warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r
// argument for arguments of type wxDateTime; it is also returned by all
// functions returning wxDateTime on failure (this is why it is also called
// wxInvalidDateTime)
-class WXDLLIMPEXP_BASE wxDateTime;
+class WXDLLIMPEXP_FWD_BASE wxDateTime;
extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat;
extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat;
GMT_6, GMT_5, GMT_4, GMT_3, GMT_2, GMT_1,
GMT0,
GMT1, GMT2, GMT3, GMT4, GMT5, GMT6,
- GMT7, GMT8, GMT9, GMT10, GMT11, GMT12,
+ GMT7, GMT8, GMT9, GMT10, GMT11, GMT12, GMT13,
// Note that GMT12 and GMT_12 are not the same: there is a difference
// of exactly one day between them
// Australia
A_WST = GMT8, // Western Standard Time
- A_CST = GMT12 + 1, // Central Standard Time (+9.5)
+ A_CST = GMT13 + 1, // Central Standard Time (+9.5)
A_EST = GMT10, // Eastern Standard Time
A_ESST = GMT11, // Eastern Summer Time
+ // New Zealand
+ NZST = GMT12, // Standard Time
+ NZDT = GMT13, // Daylight Saving Time
+
// TODO add more symbolic timezone names here
// Universal Coordinated Time = the new and politically correct name
static bool IsLeapYear(int year = Inv_Year, Calendar cal = Gregorian);
// get the century (19 for 1999, 20 for 2000 and -5 for 492 BC)
- static int GetCentury(int year = Inv_Year);
+ static int GetCentury(int year);
// returns the number of days in this year (356 or 355 for Gregorian
// calendar usually :-)
// ------------------------------------------------------------------------
// default ctor does not initialize the object, use Set()!
- wxDateTime() { m_time = wxLongLong((long)ULONG_MAX, ULONG_MAX); }
+ wxDateTime() { m_time = wxLongLong(wxINT32_MIN, 0); }
// from time_t: seconds since the Epoch 00:00:00 UTC, Jan 1, 1970)
#if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400))
// resets time to 00:00:00, doesn't change the date
wxDateTime& ResetTime();
+ // get the date part of this object only, i.e. the object which has the
+ // same date as this one but time of 00:00:00
+ wxDateTime GetDateOnly() const;
+
// the following functions don't change the values of the other
// fields, i.e. SetMinute() won't change either hour or seconds value
// if the value is out of range
inline time_t GetTicks() const;
+ // get the century, same as GetCentury(GetYear())
+ int GetCentury(const TimeZone& tz = Local) const
+ { return GetCentury(GetYear(tz)); }
// get the year (returns Inv_Year if date is invalid)
int GetYear(const TimeZone& tz = Local) const
{ return GetTm(tz).year; }
// default, they will not change if they had valid values or will
// default to Today() otherwise)
const wxChar *ParseFormat(const wxChar *date,
- const wxChar *format = wxDefaultDateTimeFormat,
+ const wxString& format = wxDefaultDateTimeFormat,
const wxDateTime& dateDef = wxDefaultDateTime);
// parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents
// argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the
// resulting text representation
- wxString Format(const wxChar *format = wxDefaultDateTimeFormat,
+ wxString Format(const wxString& format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const;
// preferred date representation for the current locale
wxString FormatDate() const { return Format(_T("%x")); }
// another one to get the current time broken down
static struct tm *GetTmNow()
{
- time_t t = GetTimeNow();
- return localtime(&t);
+ static struct tm l_CurrentTime;
+ return GetTmNow(&l_CurrentTime);
}
// get current time using thread-safe function
// resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example.
- wxString Format(const wxChar *format = wxDefaultTimeSpanFormat) const;
+ wxString Format(const wxString& format = wxDefaultTimeSpanFormat) const;
// implementation
// ------------------------------------------------------------------------
// virtual methods to work with the holidays they correspond to.
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_BASE wxDateTimeHolidayAuthority;
+class WXDLLIMPEXP_FWD_BASE wxDateTimeHolidayAuthority;
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(wxDateTimeHolidayAuthority *,
wxHolidayAuthoritiesArray,
class WXDLLIMPEXP_BASE);
return (time_t)-1;
}
- return (time_t)((m_time / (long)TIME_T_FACTOR).GetLo())+WX_TIME_BASE_OFFSET ;
+ return (time_t)((m_time / (long)TIME_T_FACTOR).ToLong()) + WX_TIME_BASE_OFFSET;
}
inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday,
inline int wxTimeSpan::GetMinutes() const
{
- return (GetSeconds() / 60l).GetLo();
+ // explicit cast to int suppresses a warning with CodeWarrior and possibly
+ // others (changing the return type to long from int is impossible in 2.8)
+ return (int)((GetSeconds() / 60l).GetLo());
}
inline int wxTimeSpan::GetHours() const