#ifndef _WX_DATE_H_
#define _WX_DATE_H_
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "date.h"
#endif
wxDate(long j) : m_date((double)(j + 0.5)) { Init(); }
wxDate(int m, int d, int y) : m_date(d, (wxDateTime::Month)m, y) { Init(); }
wxDate(const wxString& dat) { Init(); (void)m_date.ParseDate(dat); }
- wxDate(const wxDate &date) { *this = date; }
+ wxDate(const wxDate &date) : wxObject() { *this = date; }
wxDate(const wxDateTime& dt) { Init(); m_date = dt; }
long operator-(const wxDate &dt) const
{ return GetJulianDate() - dt.GetJulianDate(); }
- wxDate &operator+=(long i) { m_date += wxTimeSpan::Days(i); return *this; }
- wxDate &operator-=(long i) { m_date -= wxTimeSpan::Days(i); return *this; }
+ wxDate &operator+=(long i) { m_date += wxTimeSpan::Days((int)i); return *this; }
+ wxDate &operator-=(long i) { m_date -= wxTimeSpan::Days((int)i); return *this; }
wxDate &operator++() { return *this += 1; }
wxDate &operator++(int) { return *this += 1; }
wxDate &operator--(int) { return *this -= 1; }
#if wxUSE_STD_IOSTREAM
- friend ostream WXDLLEXPORT & operator <<(ostream &os, const wxDate &dt)
+ friend wxSTD ostream WXDLLEXPORT & operator <<(wxSTD ostream &os, const wxDate &dt)
{ return os << dt.FormatDate().mb_str(); }
#endif
// Sets to current system date
wxDate &Set()
- { m_date = wxDateTime::Today(); return *this; }
+ { m_date = wxDateTime::Today(); return (wxDate&)*this; }
wxDate &Set(long lJulian)
- { m_date.Set((double)(lJulian + 0.5)); return *this; }
+ { m_date.Set((double)(lJulian + 0.5)); return (wxDate&)*this; }
wxDate &Set(int nMonth, int nDay, int nYear)
- { m_date.Set(nDay, (wxDateTime::Month)nMonth, nYear); }
+ { m_date.Set(nDay, (wxDateTime::Month)nMonth, nYear); return *this; }
// May also pass neg# to decrement
wxDate &AddWeeks(int nCount = 1)
int GetMonth() const { return m_date.GetMonth() + 1; }
// First Date Of Month
- wxDate GetMonthStart() const { return(wxDate(GetMonth(), 1, GetYear())); }
+ wxDate GetMonthStart() const { return(wxDate(GetMonth()-1, 1, GetYear())); }
// Last Date Of Month
- wxDate GetMonthEnd() const { return wxDate(GetMonth()+1, 1, GetYear())-1; }
+ wxDate GetMonthEnd() const { return wxDate(GetMonth(), 1, GetYear())-1; }
// eg. 1992
int GetYear() const { return m_date.GetYear(); }
// First Date Of Year
- wxDate GetYearStart() const { return wxDate(1, 1, GetYear()); }
+ wxDate GetYearStart() const { return wxDate(0, 1, GetYear()); }
// Last Date Of Year
- wxDate GetYearEnd() const { return wxDate(1, 1, GetYear()+1) - 1; }
+ wxDate GetYearEnd() const { return wxDate(0, 1, GetYear()+1) - 1; }
bool IsBetween(const wxDate& first, const wxDate& second) const
{
wxDate Previous(int dayOfWeek) const
{
+ wxDate prev = *this;
int dow = GetDayOfWeek();
- if ( dayOfWeek <= dow )
- return *this - (dow - dayOfWeek);
- else
- return *this - 7 + (dayOfWeek - dow);
+ prev -= dayOfWeek > dow ? 7 - (dayOfWeek - dow) : dow - dayOfWeek;
+
+ return prev;
}
wxString FormatDate(int type = -1) const