1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: date.h
|
|
|
|
// Purpose: wxDate class
|
|
|
|
// Author: Julian Smart, Steve Marcus, Eric Simon, Chris Hill,
|
|
|
|
// Charles D. Price
|
1999-03-29 16:18:49 -05:00
|
|
|
// Modified by:
|
1998-05-20 10:01:55 -04:00
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c)
|
1999-03-29 16:18:49 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_DATE_H_
|
|
|
|
#define _WX_DATE_H_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "date.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
1999-01-24 09:57:09 -05:00
|
|
|
#if wxUSE_TIMEDATE
|
1999-02-09 11:00:23 -05:00
|
|
|
// These lines necessary to stop VC++ 6 being confused about namespaces
|
|
|
|
class WXDLLEXPORT wxDate;
|
|
|
|
bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator<(const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator <= (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator > (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator >= (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
enum wxdate_format_type {wxMDY, wxDAY, wxMONTH, wxFULL, wxEUROPEAN};
|
|
|
|
|
|
|
|
#define wxNO_CENTURY 0x02
|
|
|
|
#define wxDATE_ABBR 0x04
|
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
class WXDLLEXPORT wxDate : public wxObject
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1999-03-29 16:18:49 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxDate)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
unsigned long julian; // see julDate(); days since 1/1/4713 B.C.
|
|
|
|
int month; // see NMonth()
|
|
|
|
int day; // see Day()
|
|
|
|
int year; // see NYear4()
|
|
|
|
int day_of_week; // see NDOW(); 1 = Sunday, ... 7 = Saturday
|
|
|
|
|
|
|
|
private:
|
|
|
|
int DisplayFormat;
|
|
|
|
unsigned char DisplayOptions;
|
|
|
|
|
|
|
|
void julian_to_mdy (); // convert julian day to mdy
|
|
|
|
void julian_to_wday (); // convert julian day to day_of_week
|
|
|
|
void mdy_to_julian (); // convert mdy to julian day
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxDate ();
|
|
|
|
wxDate (long j);
|
|
|
|
wxDate (int m, int d, int y);
|
|
|
|
wxDate (const wxString& dat);
|
|
|
|
wxDate (const wxDate &dt);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-01-19 06:00:22 -05:00
|
|
|
#ifndef __SALFORDC__
|
1999-03-29 16:18:49 -05:00
|
|
|
operator wxString (void);
|
1999-01-19 06:00:22 -05:00
|
|
|
#endif
|
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
void operator = (const wxDate& date);
|
|
|
|
void operator = (const wxString& date);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate operator + (long i);
|
|
|
|
wxDate operator + (int i);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate operator - (long i);
|
|
|
|
wxDate operator - (int i);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
long operator - (const wxDate &dt);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate &operator += (long i);
|
|
|
|
wxDate &operator -= (long i);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate &operator ++ (); // Prefix increment
|
|
|
|
wxDate &operator ++ (int); // Postfix increment
|
|
|
|
wxDate &operator -- (); // Prefix decrement
|
|
|
|
wxDate &operator -- (int); // Postfix decrement
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
friend bool WXDLLEXPORT operator < (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
friend bool WXDLLEXPORT operator <= (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
friend bool WXDLLEXPORT operator > (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
friend bool WXDLLEXPORT operator >= (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
friend bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2);
|
|
|
|
friend bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2);
|
1999-01-08 11:46:20 -05:00
|
|
|
|
1999-06-27 06:39:38 -04:00
|
|
|
#if wxUSE_STD_IOSTREAM
|
1999-03-29 16:18:49 -05:00
|
|
|
friend ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt);
|
1999-06-27 06:39:38 -04:00
|
|
|
#endif
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxString FormatDate (int type=-1) const;
|
|
|
|
void SetFormat (int format);
|
|
|
|
int SetOption (int option, bool enable=TRUE);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
long GetJulianDate() const; // returns julian date
|
|
|
|
int GetDayOfYear() const; // returns relative date since Jan. 1
|
|
|
|
bool IsLeapYear() const; // returns TRUE if leap year, FALSE if not
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
// Version 4.0 Extension to Public Interface - CDP
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
// These 'Set's modify the date object and actually SET it
|
|
|
|
// They all return a reference to self (*this)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate &Set(); // Sets to current system date
|
|
|
|
wxDate &Set(long lJulian);
|
|
|
|
wxDate &Set(int nMonth, int nDay, int nYear);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxDate &AddWeeks(int nCount = 1); //
|
|
|
|
wxDate &AddMonths(int nCount = 1); // May also pass neg# to decrement
|
|
|
|
wxDate &AddYears(int nCount = 1); //
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
int GetDay() const; // Numeric Day of date object
|
|
|
|
int GetDaysInMonth(); // Number of days in month (1..31)
|
|
|
|
int GetFirstDayOfMonth() const; // First Day Of Month (1..7)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxString GetDayOfWeekName(); // Character Day Of Week ('Sunday'..'Saturday')
|
|
|
|
int GetDayOfWeek() const; // (1..7)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
int GetWeekOfMonth(); // Numeric Week Of Month (1..6)
|
|
|
|
int GetWeekOfYear(); // Numeric Week Of Year (1..52)
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
wxString GetMonthName(); // Character Month name
|
|
|
|
int GetMonth() const; // Month Number (1..12)
|
|
|
|
wxDate GetMonthStart(); // First Date Of Month
|
|
|
|
wxDate GetMonthEnd(); // Last Date Of Month
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
int GetYear() const; // eg. 1992
|
|
|
|
wxDate GetYearStart(); // First Date Of Year
|
|
|
|
wxDate GetYearEnd(); // Last Date Of Year
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
bool IsBetween(const wxDate& first, const wxDate& second) const;
|
|
|
|
|
|
|
|
wxDate Previous(int dayOfWeek) const;
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
1999-03-29 16:18:49 -05:00
|
|
|
#endif // wxUSE_TIMEDATE
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_DATE_H_
|