Removed obsolete wxDate and wxTime classes.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-03-23 20:14:19 +00:00
parent 621b931778
commit 2ab25aca26
20 changed files with 3 additions and 1660 deletions

View File

@@ -1,257 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/date.h
// Purpose: wxDate class: this class is deprecated, use wxDateTime instead!
// Author: Julian Smart, Steve Marcus, Eric Simon, Chris Hill,
// Charles D. Price
// Modified by: 18.12.99 by VZ to use the new wxDateTime class
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: Julian Smart, Steve Marcus, Eric Simon, Chris Hill,
// Charles D. Price
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DATE_H_
#define _WX_DATE_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "date.h"
#endif
#include "wx/defs.h"
#if wxUSE_TIMEDATE
#include "wx/object.h"
#include "wx/string.h"
#include "wx/datetime.h"
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
enum wxdate_format_type
{
wxMDY,
wxDAY,
wxMONTH,
wxFULL,
wxEUROPEAN
};
enum // wxdate_format_flags
{
wxNO_CENTURY = 0x02,
wxDATE_ABBR = 0x04
};
// ----------------------------------------------------------------------------
// wxDate
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDate : public wxObject
{
public:
wxDate() { Init(); }
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) : wxObject() { *this = date; }
wxDate(const wxDateTime& dt) { Init(); m_date = dt; }
#ifndef __SALFORDC__
operator wxString() const { return FormatDate(); }
#endif
void operator=(const wxDate& date)
{
m_date = date.m_date;
m_displayFormat = date.m_displayFormat;
m_displayOptions = date.m_displayOptions;
}
void operator=(const wxString& dat) { (void)m_date.ParseDate(dat); }
wxDate operator+(long i) { return wxDate(GetJulianDate() + i); }
wxDate operator+(int i) { return wxDate(GetJulianDate() + (long)i); }
wxDate operator-(long i) { return wxDate(GetJulianDate() - i); }
wxDate operator-(int i) { return wxDate(GetJulianDate() - (long)i); }
long operator-(const wxDate &dt) const
{ return GetJulianDate() - dt.GetJulianDate(); }
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--() { return *this -= 1; }
wxDate &operator--(int) { return *this -= 1; }
#if wxUSE_STD_IOSTREAM
friend wxSTD ostream WXDLLEXPORT & operator <<(wxSTD ostream &os, const wxDate &dt)
{ return os << dt.FormatDate().mb_str(); }
#endif
void SetFormat(int format) { m_displayFormat = format; }
int SetOption(int option, bool enable = TRUE)
{
if ( enable )
m_displayOptions |= option;
else
m_displayOptions &= ~option;
return 1; // (VZ: whatever it means)
}
// returns julian date (VZ: the integral part of Julian Day Number)
long GetJulianDate() const
{ return (long)(m_date.GetJulianDayNumber() - 0.5); }
// returns relative date since Jan. 1
int GetDayOfYear() const
{ return m_date.GetDayOfYear(); }
// returns TRUE if leap year, FALSE if not
bool IsLeapYear() const
{ return wxDateTime::IsLeapYear(m_date.GetYear()); }
// Sets to current system date
wxDate &Set()
{ m_date = wxDateTime::Today(); return (wxDate&)*this; }
wxDate &Set(long lJulian)
{ 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); return *this; }
// May also pass neg# to decrement
wxDate &AddWeeks(int nCount = 1)
{ m_date += wxDateSpan::Weeks(nCount); return *this; }
wxDate &AddMonths(int nCount = 1)
{ m_date += wxDateSpan::Months(nCount); return *this; }
wxDate &AddYears(int nCount = 1)
{ m_date += wxDateSpan::Years(nCount); return *this; }
// Numeric Day of date object
int GetDay() const { return m_date.GetDay(); }
// Number of days in month(1..31)
int GetDaysInMonth() const
{
return wxDateTime::GetNumberOfDays((wxDateTime::Month)m_date.GetMonth(),
m_date.GetYear());
}
// First Day Of Month(1..7)
int GetFirstDayOfMonth() const
{ return wxDate(GetMonth(), 1, GetYear()).GetDayOfWeek(); }
// Character Day Of Week('Sunday'..'Saturday')
wxString GetDayOfWeekName() const { return FormatDate(wxDAY); }
int GetDayOfWeek() const { return (int)m_date.GetWeekDay() + 1; }
// Numeric Week Of Month(1..6) (VZ: I'd love to see a month with 6 weeks)
int GetWeekOfMonth() const { return m_date.GetWeekOfMonth(); }
// Numeric Week Of Year(1..52) (VZ: but there are years with 53 weeks)
int GetWeekOfYear() const { return m_date.GetWeekOfYear(); }
// Character Month name
wxString GetMonthName() { return FormatDate(wxMONTH); }
// Month Number(1..12)
int GetMonth() const { return m_date.GetMonth() + 1; }
// First Date Of Month
wxDate GetMonthStart() const { return(wxDate(GetMonth()-1, 1, GetYear())); }
// Last Date Of Month
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(0, 1, GetYear()); }
// Last Date Of Year
wxDate GetYearEnd() const { return wxDate(0, 1, GetYear()+1) - 1; }
bool IsBetween(const wxDate& first, const wxDate& second) const
{
return m_date.IsBetween(first.m_date, second.m_date);
}
wxDate Previous(int dayOfWeek) const
{
wxDate prev = *this;
int dow = GetDayOfWeek();
prev -= dayOfWeek > dow ? 7 - (dayOfWeek - dow) : dow - dayOfWeek;
return prev;
}
wxString FormatDate(int type = -1) const
{
static const wxChar *formats[] =
{
// MDY (week)DAY MONTH FULL EUROPEAN
_T("%m/%d/%Y"), _T("%A"), _T("%B"), _T("%A, %B %d, %Y"), _T("%d %B %Y")
};
wxString fmt = formats[type == -1 ? m_displayFormat : type];
if ( m_displayOptions & wxDATE_ABBR )
{
fmt.Replace(_T("A"), _T("a"));
fmt.Replace(_T("B"), _T("b"));
}
if ( m_displayOptions & wxNO_CENTURY )
{
fmt.Replace(_T("Y"), _T("y"));
}
return m_date.Format(fmt);
}
protected:
void Init() { m_displayFormat = wxMDY; m_displayOptions = 0; }
#if 0 // the old wxDate members - unused any more
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
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
#endif // 0
private:
wxDateTime m_date;
int m_displayFormat;
int m_displayOptions;
private:
DECLARE_DYNAMIC_CLASS(wxDate)
};
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
inline bool WXDLLEXPORT operator <(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() < dt2.GetJulianDate(); }
inline bool WXDLLEXPORT operator <=(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() <= dt2.GetJulianDate(); }
inline bool WXDLLEXPORT operator >(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() > dt2.GetJulianDate(); }
inline bool WXDLLEXPORT operator >=(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() >= dt2.GetJulianDate(); }
inline bool WXDLLEXPORT operator ==(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() == dt2.GetJulianDate(); }
inline bool WXDLLEXPORT operator !=(const wxDate &dt1, const wxDate &dt2)
{ return dt1.GetJulianDate() != dt2.GetJulianDate(); }
#endif // wxUSE_TIMEDATE
#endif
// _WX_DATE_H_

View File

@@ -305,15 +305,6 @@
// Recommended setting: 1
#define wxUSE_DATETIME 1
// wxUSE_TIMEDATE enables compilation of the old wxDate and wxTime classes (not
// the same as wxDateTime!). These classes are obsolete and shouldn't be used
// in new code
//
// Default is 0
//
// Recommended setting: 0 unless you have legacy code which uses these classes
#define wxUSE_TIMEDATE 0
// Set wxUSE_TIMER to 1 to compile wxTimer class
//
// Default is 1

View File

@@ -304,15 +304,6 @@
// Recommended setting: 1
#define wxUSE_DATETIME 1
// wxUSE_TIMEDATE enables compilation of the old wxDate and wxTime classes (not
// the same as wxDateTime!). These classes are obsolete and shouldn't be used
// in new code
//
// Default is 0
//
// Recommended setting: 0 unless you have legacy code which uses these classes
#define wxUSE_TIMEDATE 0
// Set wxUSE_TIMER to 1 to compile wxTimer class
//
// Default is 1

View File

@@ -299,15 +299,6 @@
// Recommended setting: 1
#define wxUSE_DATETIME 1
// wxUSE_TIMEDATE enables compilation of the old wxDate and wxTime classes (not
// the same as wxDateTime!). These classes are obsolete and shouldn't be used
// in new code
//
// Default is 0
//
// Recommended setting: 0 unless you have legacy code which uses these classes
#define wxUSE_TIMEDATE 0
// Set wxUSE_TIMER to 1 to compile wxTimer class
//
// Default is 1

View File

@@ -1,158 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/time.h
// Purpose: wxTime class, from NIHCL: this class is deprecated, use
// wxDateTime instead
// Author: Julian Smart, after K. E. Gorlen
// Modified by: 18.12.99 by VZ to use the new wxDateTime class
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMEH__
#define _WX_TIMEH__
#include "wx/defs.h"
#if wxUSE_TIMEDATE
#include "wx/object.h"
#include "wx/datetime.h"
#include "wx/date.h"
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "time.h"
#endif
class WXDLLEXPORT wxDate;
typedef unsigned short hourTy;
typedef unsigned short minuteTy;
typedef unsigned short secondTy;
typedef unsigned long clockTy;
// seconds from 1/1/01 to 1/1/70
#define wxTIME_EPOCH_DIFF 2177452800UL
class WXDLLEXPORT wxTime : public wxObject
{
public:
// type definitions
enum tFormat { wx12h, wx24h };
enum tPrecision { wxStdMinSec, wxStdMin };
public:
// current time
wxTime() : m_time(wxDateTime::Now()) { }
wxTime(clockTy s) : m_time((time_t)(s - wxTIME_EPOCH_DIFF)) { }
void operator=(const wxTime& t) { m_time = t.m_time; }
wxTime(const wxTime& t) : wxObject() { *this = t; }
wxTime(hourTy h, minuteTy m, secondTy s = 0, bool WXUNUSED(dst) = FALSE)
: m_time(h, m, s) { }
wxTime(const wxDate& d, hourTy h = 0, minuteTy m = 0, secondTy s = 0,
bool WXUNUSED(dst) = FALSE)
: m_time(d.GetDay(), (wxDateTime::Month)d.GetMonth(), d.GetYear(),
h, m, s) { }
wxTime(const wxDateTime& time) : m_time(time) { }
// Convert to string
#ifndef __SALFORDC__
operator wxChar *() const { return FormatTime(); }
operator wxDate() const { return wxDate(m_time); }
#endif
bool operator< (const wxTime& t) const { return m_time < t.m_time; }
bool operator<=(const wxTime& t) const { return m_time <= t.m_time; }
bool operator> (const wxTime& t) const { return m_time > t.m_time; }
bool operator>=(const wxTime& t) const { return m_time >= t.m_time; }
bool operator==(const wxTime& t) const { return m_time == t.m_time; }
bool operator!=(const wxTime& t) const { return m_time != t.m_time; }
friend wxTime WXDLLEXPORT operator+(const wxTime& t, long s)
{ return wxTime(t.m_time + wxTimeSpan::Seconds((int)s)); }
friend wxTime WXDLLEXPORT operator+(long s, const wxTime& t)
{ return wxTime(t.m_time + wxTimeSpan::Seconds((int)s)); }
long operator-(const wxTime& t) const
{ return (m_time - t.m_time).GetValue().ToLong(); }
wxTime operator-(long s) const
{ return wxTime(m_time - wxTimeSpan::Seconds((int)s)); }
void operator+=(long s) { m_time += wxTimeSpan::Seconds((int)s); }
void operator-=(long s) { m_time -= wxTimeSpan::Seconds((int)s); }
bool IsBetween(const wxTime& a, const wxTime& b) const
{ return *this >= a && *this <= b; }
// Get day
int GetDay() const { return m_time.GetDay(); }
// Get month
int GetMonth() const { return m_time.GetMonth(); }
// Get year
int GetYear() const { return m_time.GetYear(); }
// Get day of week (0=Sunday 6=Saturday)
int GetDayOfWeek() const { return m_time.GetWeekDay(); }
hourTy GetHour() const { return (hourTy)m_time.GetHour(); }
hourTy GetHourGMT() const { return (hourTy)m_time.GetHour(wxDateTime::GMT0); }
minuteTy GetMinute() const { return (hourTy)m_time.GetMinute(); }
minuteTy GetMinuteGMT() const { return (hourTy)m_time.GetMinute(wxDateTime::GMT0); }
secondTy GetSecond() const { return (hourTy)m_time.GetSecond(); }
secondTy GetSecondGMT() const { return (hourTy)m_time.GetSecond(wxDateTime::GMT0); }
clockTy GetSeconds() const { return (clockTy)m_time.GetValue().ToLong(); }
wxTime Max(const wxTime& t) const { return (t < *this) ? *this : t; }
wxTime Min(const wxTime& t) const { return (t > *this) ? *this : t; }
static void SetFormat(const tFormat lFormat = wx12h,
const tPrecision lPrecision = wxStdMinSec)
{
ms_Format = lFormat;
ms_Precision = lPrecision;
}
// (VZ: DANGER: returns pointer to static buffer)
wxChar *FormatTime() const
{
static const wxChar *formats[2][2] =
{
// wxStdMinSec wxStdMin
{ _T("%I:%M:%S %p"), _T("%I:%M %p") }, // wx12h
{ _T("%H:%M:%S"), _T("%H:%M") } // wx24h
};
wxStrncpy(ms_bufTime, m_time.Format(formats[ms_Format][ms_Precision]),
WXSIZEOF(ms_bufTime));
return ms_bufTime;
}
private:
static tFormat ms_Format;
static tPrecision ms_Precision;
static wxChar ms_bufTime[128];
#if 0 // old wxTime members unused any more
clockTy sec; /* seconds since 1/1/1901 */
bool IsDST() const;
wxTime GetLocalTime() const;
// static member functions
static wxTime GetLocalTime(const wxDate& date, hourTy h=0, minuteTy m=0, secondTy s=0);
static wxTime GetBeginDST(unsigned year);
static wxTime GetEndDST(unsigned year);
#endif // 0
wxDateTime m_time;
DECLARE_DYNAMIC_CLASS(wxTime)
};
#endif
// wxUSE_TIMEDATE
#endif
// _WX_TIMEH__

View File

@@ -21,11 +21,6 @@
#include "wx/string.h"
#include "wx/list.h"
#if wxUSE_TIMEDATE
#include "wx/time.h"
#include "wx/date.h"
#endif // time/date
#if wxUSE_DATETIME
#include "wx/datetime.h"
#endif // wxUSE_DATETIME
@@ -99,11 +94,6 @@ public:
wxVariant(const wxChar* val, const wxString& name = wxEmptyString); // Necessary or VC++ assumes bool!
wxVariant(const wxStringList& val, const wxString& name = wxEmptyString);
wxVariant(const wxList& val, const wxString& name = wxEmptyString); // List of variants
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
wxVariant(const wxTime& val, const wxString& name = wxEmptyString); // Time
wxVariant(const wxDate& val, const wxString& name = wxEmptyString); // Date
#endif
wxVariant(void* ptr, const wxString& name = wxEmptyString); // void* (general purpose)
wxVariant(wxVariantData* data, const wxString& name = wxEmptyString); // User-defined data
//TODO: Need to document
@@ -173,15 +163,6 @@ public:
bool operator== (const wxList& value) const;
bool operator!= (const wxList& value) const;
void operator= (const wxList& value) ;
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
bool operator== (const wxTime& value) const;
bool operator!= (const wxTime& value) const;
void operator= (const wxTime& value) ;
bool operator== (const wxDate& value) const;
bool operator!= (const wxDate& value) const;
void operator= (const wxDate& value) ;
#endif
bool operator== (void* value) const;
bool operator!= (void* value) const;
void operator= (void* value) ;
@@ -199,11 +180,6 @@ public:
inline operator char () const { return GetChar(); }
inline operator long () const { return GetLong(); }
inline operator bool () const { return GetBool(); }
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
inline operator wxTime () const { return GetTime(); }
inline operator wxDate () const { return GetDate(); }
#endif
inline operator void* () const { return GetVoidPtr(); }
//TODO: Need to document
#if wxUSE_DATETIME
@@ -242,11 +218,6 @@ public:
wxList& GetList() const ;
wxStringList& GetStringList() const ;
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
wxTime GetTime() const ;
wxDate GetDate() const ;
#endif
void* GetVoidPtr() const ;
//TODO: Need to document
#if wxUSE_DATETIME
@@ -285,11 +256,6 @@ public:
bool Convert(double* value) const;
bool Convert(wxString* value) const;
bool Convert(char* value) const;
// For some reason, Watcom C++ can't link variant.cpp with time/date classes compiled
#if wxUSE_TIMEDATE && !defined(__WATCOMC__)
bool Convert(wxTime* value) const;
bool Convert(wxDate* value) const;
#endif
//TODO: Need to document
#if wxUSE_DATETIME
bool Convert(wxDateTime* value) const;