X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b781a6729859abc77e6ca5b1f81cbaad974a78f..6def7a17b01a15e68696a1863d114ecc5554e3d4:/include/wx/datetime.inl diff --git a/include/wx/datetime.inl b/include/wx/datetime.inl index 3089b32111..546de23f8a 100644 --- a/include/wx/datetime.inl +++ b/include/wx/datetime.inl @@ -35,11 +35,6 @@ // wxDateTime construction // ---------------------------------------------------------------------------- -// only define this once, when included from datetime.cpp -#ifdef wxDEFINE_TIME_CONSTANTS - const long wxDateTime::TIME_T_FACTOR = 1000l; -#endif // wxDEFINE_TIME_CONSTANTS - inline bool wxDateTime::IsInStdRange() const { return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX; @@ -54,12 +49,12 @@ inline wxDateTime wxDateTime::Now() /* static */ inline wxDateTime wxDateTime::Today() { - struct tm *tm = GetTmNow(); - tm->tm_hour = - tm->tm_min = - tm->tm_sec = 0; + struct tm *time = GetTmNow(); + time->tm_hour = 0; + time->tm_min = 0; + time->tm_sec = 0; - return wxDateTime(*tm); + return wxDateTime(*time); } #if (!(defined(__VISAGECPP__) && __IBMCPP__ >= 400)) @@ -105,7 +100,8 @@ inline wxDateTime& wxDateTime::Set(const Tm& tm) { wxASSERT_MSG( tm.IsValid(), _T("invalid broken down date/time") ); - return Set(tm.mday, (Month)tm.mon, tm.year, tm.hour, tm.min, tm.sec); + return Set(tm.mday, (Month)tm.mon, tm.year, + tm.hour, tm.min, tm.sec, tm.msec); } inline wxDateTime::wxDateTime(wxDateTime_t hour, @@ -149,14 +145,15 @@ inline time_t wxDateTime::GetTicks() const return (time_t)((m_time / (long)TIME_T_FACTOR).GetLo())+WX_TIME_BASE_OFFSET ; } -bool wxDateTime::SetToLastWeekDay(WeekDay weekday, +inline bool wxDateTime::SetToLastWeekDay(WeekDay weekday, Month month, int year) { return SetToWeekDay(weekday, -1, month, year); } -inline wxDateTime wxDateTime::GetWeekDayInSameWeek(WeekDay weekday) const +inline wxDateTime wxDateTime::GetWeekDayInSameWeek(WeekDay weekday, + WeekFlags flags) const { MODIFY_AND_RETURN( SetToWeekDayInSameWeek(weekday) ); } @@ -191,11 +188,12 @@ inline wxDateTime wxDateTime::GetLastWeekDay(WeekDay weekday, } inline wxDateTime wxDateTime::GetWeek(wxDateTime_t numWeek, - WeekDay weekday) const + WeekDay weekday, + WeekFlags flags) const { wxDateTime dt(*this); - return dt.SetToTheWeek(numWeek, weekday) ? dt : wxInvalidDateTime; + return dt.SetToTheWeek(numWeek, weekday, flags) ? dt : wxInvalidDateTime; } inline wxDateTime wxDateTime::GetLastMonthDay(Month month, int year) const @@ -249,7 +247,12 @@ inline bool wxDateTime::IsBetween(const wxDateTime& t1, inline bool wxDateTime::IsSameDate(const wxDateTime& dt) const { - return (m_time - dt.m_time).Abs() < MILLISECONDS_PER_DAY; + Tm tm1 = GetTm(), + tm2 = dt.GetTm(); + + return tm1.year == tm2.year && + tm1.mon == tm2.mon && + tm1.mday == tm2.mday; } inline bool wxDateTime::IsSameTime(const wxDateTime& dt) const