Version: 2.9.4
Classes | Public Types | Static Public Member Functions
wxDateTime Class Reference

#include </home/zeitlin/src/wx/github/interface/wx/datetime.h>


Detailed Description

wxDateTime class represents an absolute moment in time.

The type wxDateTime_t is typedefed as unsigned short and is used to contain the number of years, hours, minutes, seconds and milliseconds.

Global constant wxDefaultDateTime and synonym for it wxInvalidDateTime are defined. This constant will be different from any valid wxDateTime object.

Static Functions

All static functions either set or return the static variables of wxDateSpan (the country), return the current moment, year, month or number of days in it, or do some general calendar-related actions.

Please note that although several function accept an extra Calendar parameter, it is currently ignored as only the Gregorian calendar is supported. Future versions will support other calendars.

Date Formatting and Parsing

The date formatting and parsing functions convert wxDateTime objects to and from text. The conversions to text are mostly trivial: you can either do it using the default date and time representations for the current locale (FormatDate() and FormatTime()), using the international standard representation defined by ISO 8601 (FormatISODate(), FormatISOTime() and FormatISOCombined()) or by specifying any format at all and using Format() directly.

The conversions from text are more interesting, as there are much more possibilities to care about. The simplest cases can be taken care of with ParseFormat() which can parse any date in the given (rigid) format. ParseRfc822Date() is another function for parsing dates in predefined format -- the one of RFC 822 which (still...) defines the format of email messages on the Internet. This format cannot be described with strptime(3)-like format strings used by Format(), hence the need for a separate function.

But the most interesting functions are ParseTime(), ParseDate() and ParseDateTime(). They try to parse the date and time (or only one of them) in 'free' format, i.e. allow them to be specified in any of possible ways. These functions will usually be used to parse the (interactive) user input which is not bound to be in any predefined format. As an example, ParseDate() can parse the strings such as "tomorrow", "March first" and even "next Sunday".

Finally notice that each of the parsing functions is available in several overloads: if the input string is a narrow (char *) string, then a narrow pointer is returned. If the input string is a wide string, a wide char pointer is returned. Finally, if the input parameter is a wxString, a narrow char pointer is also returned for backwards compatibility but there is also an additional argument of wxString::const_iterator type in which, if it is not NULL, an iterator pointing to the end of the scanned string part is returned.

Library:  wxBase
Category:  Data Structures

Predefined objects/pointers:

参照:
Date and Time, wxTimeSpan, wxDateSpan, wxCalendarCtrl

クラス

class  TimeZone
 Class representing a time zone. More...
struct  Tm
 Contains broken down date-time representation. More...

Public Types

enum  TZ {
  Local,
  GMT_12,
  GMT_11,
  GMT_10,
  GMT_9,
  GMT_8,
  GMT_7,
  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,
  GMT13,
  WET = GMT0,
  WEST = GMT1,
  CET = GMT1,
  CEST = GMT2,
  EET = GMT2,
  EEST = GMT3,
  MSK = GMT3,
  MSD = GMT4,
  AST = GMT_4,
  ADT = GMT_3,
  EST = GMT_5,
  EDT = GMT_4,
  CST = GMT_6,
  CDT = GMT_5,
  MST = GMT_7,
  MDT = GMT_6,
  PST = GMT_8,
  PDT = GMT_7,
  HST = GMT_10,
  AKST = GMT_9,
  AKDT = GMT_8,
  A_WST = GMT8,
  A_CST = GMT13 + 1,
  A_EST = GMT10,
  A_ESST = GMT11,
  NZST = GMT12,
  NZDT = GMT13,
  UTC = GMT0
}
 Time zone symbolic names. More...
enum  Calendar {
  Gregorian,
  Julian
}
 Several functions accept an extra parameter specifying the calendar to use (although most of them only support now the Gregorian calendar). More...
enum  GregorianAdoption {
  Gr_Unknown,
  Gr_Standard,
  Gr_Alaska,
  Gr_Albania,
  Gr_Austria = Gr_Unknown,
  Gr_Austria_Brixen,
  Gr_Austria_Salzburg = Gr_Austria_Brixen,
  Gr_Austria_Tyrol = Gr_Austria_Brixen,
  Gr_Austria_Carinthia,
  Gr_Austria_Styria = Gr_Austria_Carinthia,
  Gr_Belgium,
  Gr_Bulgaria = Gr_Unknown,
  Gr_Bulgaria_1,
  Gr_Bulgaria_2,
  Gr_Bulgaria_3,
  Gr_Canada = Gr_Unknown,
  Gr_China = Gr_Unknown,
  Gr_China_1,
  Gr_China_2,
  Gr_Czechoslovakia,
  Gr_Denmark,
  Gr_Egypt,
  Gr_Estonia,
  Gr_Finland,
  Gr_France,
  Gr_France_Alsace,
  Gr_France_Lorraine,
  Gr_France_Strasbourg,
  Gr_Germany = Gr_Unknown,
  Gr_Germany_Catholic,
  Gr_Germany_Prussia,
  Gr_Germany_Protestant,
  Gr_GreatBritain,
  Gr_Greece,
  Gr_Hungary,
  Gr_Ireland = Gr_GreatBritain,
  Gr_Italy = Gr_Standard,
  Gr_Japan = Gr_Unknown,
  Gr_Japan_1,
  Gr_Japan_2,
  Gr_Japan_3,
  Gr_Latvia,
  Gr_Lithuania,
  Gr_Luxemburg,
  Gr_Netherlands = Gr_Belgium,
  Gr_Netherlands_Groningen,
  Gr_Netherlands_Gelderland,
  Gr_Netherlands_Utrecht,
  Gr_Netherlands_Friesland,
  Gr_Norway = Gr_Denmark,
  Gr_Poland = Gr_Standard,
  Gr_Portugal = Gr_Standard,
  Gr_Romania,
  Gr_Russia,
  Gr_Scotland = Gr_GreatBritain,
  Gr_Spain = Gr_Standard,
  Gr_Sweden = Gr_Finland,
  Gr_Switzerland = Gr_Unknown,
  Gr_Switzerland_Catholic,
  Gr_Switzerland_Protestant,
  Gr_Turkey,
  Gr_USA = Gr_GreatBritain,
  Gr_Wales = Gr_GreatBritain,
  Gr_Yugoslavia
}
 Values corresponding to different dates of adoption of the Gregorian calendar. More...
enum  Country {
  Country_Unknown,
  Country_Default,
  Country_WesternEurope_Start,
  Country_EEC = Country_WesternEurope_Start,
  France,
  Germany,
  UK,
  Country_WesternEurope_End = UK,
  Russia,
  USA
}
 Date calculations often depend on the country and wxDateTime allows to set the country whose conventions should be used using SetCountry(). More...
enum  Month {
  Jan,
  Feb,
  Mar,
  Apr,
  May,
  Jun,
  Jul,
  Aug,
  Sep,
  Oct,
  Nov,
  Dec,
  Inv_Month
}
 symbolic names for the months More...
enum  WeekDay {
  Sun,
  Mon,
  Tue,
  Wed,
  Thu,
  Fri,
  Sat,
  Inv_WeekDay
}
 symbolic names for the weekdays More...
enum  Year { Inv_Year = SHRT_MIN }
 invalid value for the year More...
enum  NameFlags {
  Name_Full = 0x01,
  Name_Abbr = 0x02
}
 Flags to be used with GetMonthName() and GetWeekDayName() functions. More...
enum  WeekFlags {
  Default_First,
  Monday_First,
  Sunday_First
}
 Different parts of the world use different conventions for the week start. More...
typedef unsigned short wxDateTime_t
 A small unsigned integer type for storing things like minutes, seconds &c.

Public Member Functions

Constructors, Assignment Operators and Setters

Constructors and various Set() methods are collected here.

If you construct a date object from separate values for day, month and year, you should use IsValid() method to check that the values were correct as constructors cannot return an error code.

 wxDateTime ()
 Default constructor.
 wxDateTime (const wxDateTime &date)
 Copy constructor.
 wxDateTime (time_t timet)
 Same as Set().
 wxDateTime (const struct tm &tm)
 Same as Set().
 wxDateTime (double jdn)
 Same as Set().
 wxDateTime (wxDateTime_t hour, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0)
 Same as Set().
 wxDateTime (wxDateTime_t day, Month month, int year=Inv_Year, wxDateTime_t hour=0, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0)
 Same as Set().
 wxDateTime (const struct _SYSTEMTIME &st)
 Same as SetFromMSWSysTime.
wxDateTimeResetTime ()
 Reset time to midnight (00:00:00) without changing the date.
wxDateTimeSet (time_t timet)
 Constructs the object from timet value holding the number of seconds since Jan 1, 1970.
wxDateTimeSet (const struct tm &tm)
 Sets the date and time from the broken down representation in the standard tm structure.
wxDateTimeSet (const Tm &tm)
 Sets the date and time from the broken down representation in the wxDateTime::Tm structure.
wxDateTimeSet (double jdn)
 Sets the date from the so-called Julian Day Number.
wxDateTimeSet (wxDateTime_t hour, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0)
 Sets the date to be equal to Today() and the time from supplied parameters.
wxDateTimeSet (wxDateTime_t day, Month month, int year=Inv_Year, wxDateTime_t hour=0, wxDateTime_t minute=0, wxDateTime_t second=0, wxDateTime_t millisec=0)
 Sets the date and time from the parameters.
wxDateTimeSetDay (unsigned short day)
 Sets the day without changing other date components.
wxDateTimeSetFromDOS (unsigned long ddt)
 Sets the date from the date and time in DOS format.
wxDateTimeSetHour (unsigned short hour)
 Sets the hour without changing other date components.
wxDateTimeSetMillisecond (unsigned short millisecond)
 Sets the millisecond without changing other date components.
wxDateTimeSetMinute (unsigned short minute)
 Sets the minute without changing other date components.
wxDateTimeSetMonth (Month month)
 Sets the month without changing other date components.
wxDateTimeSetSecond (unsigned short second)
 Sets the second without changing other date components.
wxDateTimeSetToCurrent ()
 Sets the date and time of to the current values.
wxDateTimeSetYear (int year)
 Sets the year without changing other date components.
wxDateTimeoperator= (time_t timet)
 Same as Set().
wxDateTimeoperator= (const struct tm &tm)
 Same as Set().
Accessors

Here are the trivial accessors.

Other functions, which might have to perform some more complicated calculations to find the answer are under the "Date Arithmetics" section.

unsigned long GetAsDOS () const
 Returns the date and time in DOS format.
wxDateTimeSetFromMSWSysTime (const struct _SYSTEMTIME &st)
 Initialize using the Windows SYSTEMTIME structure.
void GetAsMSWSysTime (struct _SYSTEMTIME *st) const
 Returns the date and time in the Windows SYSTEMTIME format.
int GetCentury (const TimeZone &tz=Local) const
 Returns the century of this date.
wxDateTime GetDateOnly () const
 Returns the object having the same date component as this one but time of 00:00:00.
unsigned short GetDay (const TimeZone &tz=Local) const
 Returns the day in the given timezone (local one by default).
unsigned short GetDayOfYear (const TimeZone &tz=Local) const
 Returns the day of the year (in 1-366 range) in the given timezone (local one by default).
unsigned short GetHour (const TimeZone &tz=Local) const
 Returns the hour in the given timezone (local one by default).
unsigned short GetMillisecond (const TimeZone &tz=Local) const
 Returns the milliseconds in the given timezone (local one by default).
unsigned short GetMinute (const TimeZone &tz=Local) const
 Returns the minute in the given timezone (local one by default).
Month GetMonth (const TimeZone &tz=Local) const
 Returns the month in the given timezone (local one by default).
unsigned short GetSecond (const TimeZone &tz=Local) const
 Returns the seconds in the given timezone (local one by default).
time_t GetTicks () const
 Returns the number of seconds since Jan 1, 1970.
Tm GetTm (const TimeZone &tz=Local) const
 Returns broken down representation of the date and time.
WeekDay GetWeekDay (const TimeZone &tz=Local) const
 Returns the week day in the given timezone (local one by default).
wxDateTime_t GetWeekOfMonth (WeekFlags flags=Monday_First, const TimeZone &tz=Local) const
 Returns the ordinal number of the week in the month (in 1-5 range).
wxDateTime_t GetWeekOfYear (WeekFlags flags=Monday_First, const TimeZone &tz=Local) const
 Returns the number of the week of the year this date is in.
int GetYear (const TimeZone &tz=Local) const
 Returns the year in the given timezone (local one by default).
bool IsGregorianDate (GregorianAdoption country=Gr_Standard) const
 Returns true if the given date is later than the date of adoption of the Gregorian calendar in the given country (and hence the Gregorian calendar calculations make sense for it).
bool IsValid () const
 Returns true if the object represents a valid time moment.
bool IsWorkDay (Country country=Country_Default) const
 Returns true is this day is not a holiday in the given country.
Date Comparison

There are several functions to allow date comparison.

To supplement them, a few global operators, etc taking wxDateTime are defined.

bool IsEarlierThan (const wxDateTime &datetime) const
 Returns true if this date precedes the given one.
bool IsEqualTo (const wxDateTime &datetime) const
 Returns true if the two dates are strictly identical.
bool IsEqualUpTo (const wxDateTime &dt, const wxTimeSpan &ts) const
 Returns true if the date is equal to another one up to the given time interval, i.e.
bool IsLaterThan (const wxDateTime &datetime) const
 Returns true if this date is later than the given one.
bool IsSameDate (const wxDateTime &dt) const
 Returns true if the date is the same without comparing the time parts.
bool IsSameTime (const wxDateTime &dt) const
 Returns true if the time is the same (although dates may differ).
bool IsStrictlyBetween (const wxDateTime &t1, const wxDateTime &t2) const
 Returns true if this date lies strictly between the two given dates.
bool IsBetween (const wxDateTime &t1, const wxDateTime &t2) const
 Returns true if IsStrictlyBetween() is true or if the date is equal to one of the limit values.
Date Arithmetics

These functions carry out arithmetics on the wxDateTime objects.

As explained in the overview, either wxTimeSpan or wxDateSpan may be added to wxDateTime, hence all functions are overloaded to accept both arguments.

Also, both Add() and Subtract() have both const and non-const version. The first one returns a new object which represents the sum/difference of the original one with the argument while the second form modifies the object to which it is applied. The operators "-=" and "+=" are defined to be equivalent to the second forms of these functions.

wxDateTime Add (const wxDateSpan &diff) const
 Adds the given date span to this object.
wxDateTime Add (const wxDateSpan &diff)
 Adds the given date span to this object.
wxDateTime Add (const wxTimeSpan &diff) const
 Adds the given time span to this object.
wxDateTimeAdd (const wxTimeSpan &diff)
 Adds the given time span to this object.
wxDateTime Subtract (const wxTimeSpan &diff) const
 Subtracts the given time span from this object.
wxDateTimeSubtract (const wxTimeSpan &diff)
 Subtracts the given time span from this object.
wxDateTime Subtract (const wxDateSpan &diff) const
 Subtracts the given date span from this object.
wxDateTimeSubtract (const wxDateSpan &diff)
 Subtracts the given date span from this object.
wxTimeSpan Subtract (const wxDateTime &dt) const
 Subtracts another date from this one and returns the difference between them as a wxTimeSpan.
wxDateTimeoperator+= (const wxDateSpan &diff)
 Adds the given date span to this object.
wxDateTimeoperator-= (const wxDateSpan &diff)
 Subtracts the given date span from this object.
wxDateTimeoperator+= (const wxTimeSpan &diff)
 Adds the given time span to this object.
wxDateTimeoperator-= (const wxTimeSpan &diff)
 Subtracts the given time span from this object.
Date Formatting and Parsing
wxString Format (const wxString &format=wxDefaultDateTimeFormat, const TimeZone &tz=Local) const
 This function does the same as the standard ANSI C strftime(3) function (http://www.cplusplus.com/reference/clibrary/ctime/strftime.html).
wxString FormatDate () const
 Identical to calling Format() with "%x" argument (which means "preferred date representation for the current locale").
wxString FormatISOCombined (char sep= 'T') const
 Returns the combined date-time representation in the ISO 8601 format "YYYY-MM-DDTHH:MM:SS".
wxString FormatISODate () const
 This function returns the date representation in the ISO 8601 format "YYYY-MM-DD".
wxString FormatISOTime () const
 This function returns the time representation in the ISO 8601 format "HH:MM:SS".
wxString FormatTime () const
 Identical to calling Format() with "%X" argument (which means "preferred time representation for the current locale").
bool ParseDate (const wxString &date, wxString::const_iterator *end)
 This function is like ParseDateTime(), but it only allows the date to be specified.
bool ParseDateTime (const wxString &datetime, wxString::const_iterator *end)
 Parses the string datetime containing the date and time in free format.
bool ParseFormat (const wxString &date, const wxString &format, const wxDateTime &dateDef, wxString::const_iterator *end)
 This function parses the string date according to the given format.
bool ParseFormat (const wxString &date, const wxString &format, wxString::const_iterator *end)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool ParseFormat (const wxString &date, wxString::const_iterator *end)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool ParseISOCombined (const wxString &date, char sep= 'T')
 This function parses the string containing the date and time in ISO 8601 combined format "YYYY-MM-DDTHH:MM:SS".
bool ParseISODate (const wxString &date)
 This function parses the date in ISO 8601 format "YYYY-MM-DD".
bool ParseISOTime (const wxString &date)
 This function parses the time in ISO 8601 format "HH:MM:SS".
bool ParseRfc822Date (const wxString &date, wxString::const_iterator *end)
 Parses the string date looking for a date formatted according to the RFC 822 in it.
bool ParseTime (const wxString &time, wxString::const_iterator *end)
 This functions is like ParseDateTime(), but only allows the time to be specified in the input string.
Calendar Calculations

The functions in this section perform the basic calendar calculations, mostly related to the week days.

They allow to find the given week day in the week with given number (either in the month or in the year) and so on.

None of the functions in this section modify the time part of the wxDateTime, they only work with the date part of it.

wxDateTime GetLastMonthDay (Month month=Inv_Month, int year=Inv_Year) const
 Returns the copy of this object to which SetToLastMonthDay() was applied.
wxDateTime GetLastWeekDay (WeekDay weekday, Month month=Inv_Month, int year=Inv_Year)
 Returns the copy of this object to which SetToLastWeekDay() was applied.
wxDateTime GetNextWeekDay (WeekDay weekday) const
 Returns the copy of this object to which SetToNextWeekDay() was applied.
wxDateTime GetPrevWeekDay (WeekDay weekday) const
 Returns the copy of this object to which SetToPrevWeekDay() was applied.
wxDateTime GetWeekDay (WeekDay weekday, int n=1, Month month=Inv_Month, int year=Inv_Year) const
 Returns the copy of this object to which SetToWeekDay() was applied.
wxDateTime GetWeekDayInSameWeek (WeekDay weekday, WeekFlags flags=Monday_First) const
 Returns the copy of this object to which SetToWeekDayInSameWeek() was applied.
wxDateTime GetYearDay (wxDateTime_t yday) const
 Returns the copy of this object to which SetToYearDay() was applied.
wxDateTimeSetToLastMonthDay (Month month=Inv_Month, int year=Inv_Year)
 Sets the date to the last day in the specified month (the current one by default).
bool SetToLastWeekDay (WeekDay weekday, Month month=Inv_Month, int year=Inv_Year)
 The effect of calling this function is the same as of calling SetToWeekDay(-1, weekday, month, year).
wxDateTimeSetToNextWeekDay (WeekDay weekday)
 Sets the date so that it will be the first weekday following the current date.
wxDateTimeSetToPrevWeekDay (WeekDay weekday)
 Sets the date so that it will be the last weekday before the current date.
bool SetToWeekDay (WeekDay weekday, int n=1, Month month=Inv_Month, int year=Inv_Year)
 Sets the date to the n-th weekday in the given month of the given year (the current month and year are used by default).
wxDateTimeSetToWeekDayInSameWeek (WeekDay weekday, WeekFlags flags=Monday_First)
 Adjusts the date so that it will still lie in the same week as before, but its week day will be the given one.
wxDateTimeSetToYearDay (wxDateTime_t yday)
 Sets the date to the day number yday in the same year (i.e., unlike the other functions, this one does not use the current year).
Astronomical/Historical Functions

Some degree of support for the date units used in astronomy and/or history is provided.

You can construct a wxDateTime object from a JDN and you may also get its JDN, MJD or Rata Die number from it.

Related functions in other groups: wxDateTime(double), Set(double)

double GetJDN () const
 Synonym for GetJulianDayNumber().
double GetJulianDayNumber () const
 Returns the JDN corresponding to this date.
double GetMJD () const
 Synonym for GetModifiedJulianDayNumber().
double GetModifiedJulianDayNumber () const
 Returns the "Modified Julian Day Number" (MJD) which is, by definition, is equal to JDN - 2400000.5.
double GetRataDie () const
 Return the Rata Die number of this date.
Time Zone and DST Support

Please see the time zone overview for more information about time zones.

Normally, these functions should be rarely used.

Related functions in other groups: GetBeginDST(), GetEndDST()

wxDateTime FromTimezone (const TimeZone &tz, bool noDST=false) const
 Transform the date from the given time zone to the local one.
int IsDST (Country country=Country_Default) const
 Returns true if the DST is applied for this date in the given country.
wxDateTimeMakeFromTimezone (const TimeZone &tz, bool noDST=false)
 Same as FromTimezone() but modifies the object in place.
wxDateTimeMakeTimezone (const TimeZone &tz, bool noDST=false)
 Modifies the object in place to represent the date in another time zone.
wxDateTimeMakeUTC (bool noDST=false)
 This is the same as calling MakeTimezone() with the argument GMT0.
wxDateTime ToTimezone (const TimeZone &tz, bool noDST=false) const
 Transform the date to the given time zone.
wxDateTime ToUTC (bool noDST=false) const
 This is the same as calling ToTimezone() with the argument GMT0.

Static Public Member Functions

static int ConvertYearToBC (int year)
 Converts the year in absolute notation (i.e.
static void GetAmPmStrings (wxString *am, wxString *pm)
 Returns the translations of the strings AM and PM used for time formatting for the current locale.
static wxDateTime GetBeginDST (int year=Inv_Year, Country country=Country_Default)
 Get the beginning of DST for the given country in the given year (current one by default).
static wxDateTime GetEndDST (int year=Inv_Year, Country country=Country_Default)
 Returns the end of DST for the given country in the given year (current one by default).
static int GetCentury (int year)
 Get the current century, i.e.
static Country GetCountry ()
 Returns the current default country.
static Month GetCurrentMonth (Calendar cal=Gregorian)
 Get the current month in given calendar (only Gregorian is currently supported).
static int GetCurrentYear (Calendar cal=Gregorian)
 Get the current year in given calendar (only Gregorian is currently supported).
static wxString GetEnglishMonthName (Month month, NameFlags flags=Name_Full)
 Return the standard English name of the given month.
static wxString GetEnglishWeekDayName (WeekDay weekday, NameFlags flags=Name_Full)
 Return the standard English name of the given week day.
static wxString GetMonthName (Month month, NameFlags flags=Name_Full)
 Gets the full (default) or abbreviated name of the given month.
static wxDateTime_t GetNumberOfDays (int year, Calendar cal=Gregorian)
 Returns the number of days in the given year.
static wxDateTime_t GetNumberOfDays (Month month, int year=Inv_Year, Calendar cal=Gregorian)
 Returns the number of days in the given month of the given year.
static time_t GetTimeNow ()
 Returns the current time.
static tm * GetTmNow (struct tm *tm)
 Returns the current time broken down using the buffer whose address is passed to the function with tm to store the result.
static tm * GetTmNow ()
 Returns the current time broken down.
static wxString GetWeekDayName (WeekDay weekday, NameFlags flags=Name_Full)
 Gets the full (default) or abbreviated name of the given week day.
static bool IsDSTApplicable (int year=Inv_Year, Country country=Country_Default)
 Returns true if DST was used in the given year (the current one by default) in the given country.
static bool IsLeapYear (int year=Inv_Year, Calendar cal=Gregorian)
 Returns true if the year is a leap one in the specified calendar.
static bool IsWestEuropeanCountry (Country country=Country_Default)
 This function returns true if the specified (or default) country is one of Western European ones.
static wxDateTime Now ()
 Returns the object corresponding to the current time.
static void SetCountry (Country country)
 Sets the country to use by default.
static wxDateTime SetToWeekOfYear (int year, wxDateTime_t numWeek, WeekDay weekday=Mon)
 Set the date to the given weekday in the week number numWeek of the given year .
static wxDateTime Today ()
 Returns the object corresponding to the midnight of the current day (i.e.
static wxDateTime UNow ()
 Returns the object corresponding to the current UTC time including the milliseconds.

List of all members.


Member Typedef Documentation

typedef unsigned short wxDateTime::wxDateTime_t

A small unsigned integer type for storing things like minutes, seconds &c.

It should be at least short (i.e. not char) to contain the number of milliseconds - it may also be 'int' because there is no size penalty associated with it in our code, we don't store any data in this format.


Member Enumeration Documentation

Several functions accept an extra parameter specifying the calendar to use (although most of them only support now the Gregorian calendar).

This parameters is one of the following values.

Enumerator:
Gregorian 

calendar currently in use in Western countries

Julian 

calendar in use since -45 until the 1582 (or later)

Date calculations often depend on the country and wxDateTime allows to set the country whose conventions should be used using SetCountry().

It takes one of the following values as parameter.

Enumerator:
Country_Unknown 

no special information for this country

Country_Default 

set the default country with SetCountry() method or use the default country with any other

Country_WesternEurope_Start 
Country_EEC 
France 
Germany 
UK 
Country_WesternEurope_End 
Russia 
USA 

Values corresponding to different dates of adoption of the Gregorian calendar.

参照:
IsGregorianDate
Enumerator:
Gr_Unknown 

no data for this country or it's too uncertain to use

Gr_Standard 

on the day 0 of Gregorian calendar: 15 Oct 1582

Gr_Alaska 

Oct 1867 when Alaska became part of the USA.

Gr_Albania 

Dec 1912.

Gr_Austria 

Different regions on different dates.

Gr_Austria_Brixen 

5 Oct 1583 -> 16 Oct 1583

Gr_Austria_Salzburg 
Gr_Austria_Tyrol 
Gr_Austria_Carinthia 

14 Dec 1583 -> 25 Dec 1583

Gr_Austria_Styria 
Gr_Belgium 

Then part of the Netherlands.

Gr_Bulgaria 

Unknown precisely (from 1915 to 1920)

Gr_Bulgaria_1 

18 Mar 1916 -> 1 Apr 1916

Gr_Bulgaria_2 

31 Mar 1916 -> 14 Apr 1916

Gr_Bulgaria_3 

3 Sep 1920 -> 17 Sep 1920

Gr_Canada 

Different regions followed the changes in.

Great Britain or France

Gr_China 

Different authorities say:

Gr_China_1 

18 Dec 1911 -> 1 Jan 1912

Gr_China_2 

18 Dec 1928 -> 1 Jan 1929

Gr_Czechoslovakia 

(Bohemia and Moravia) 6 Jan 1584 -> 17 Jan 1584

Gr_Denmark 

(including Norway) 18 Feb 1700 -> 1 Mar 1700

Gr_Egypt 

1875

Gr_Estonia 

1918

Gr_Finland 

Then part of Sweden.

Gr_France 

9 Dec 1582 -> 20 Dec 1582

Gr_France_Alsace 

4 Feb 1682 -> 16 Feb 1682

Gr_France_Lorraine 

16 Feb 1760 -> 28 Feb 1760

Gr_France_Strasbourg 

February 1682.

Gr_Germany 

Different states on different dates:

Gr_Germany_Catholic 

1583-1585 (we take 1584)

Gr_Germany_Prussia 

22 Aug 1610 -> 2 Sep 1610

Gr_Germany_Protestant 

18 Feb 1700 -> 1 Mar 1700

Gr_GreatBritain 

2 Sep 1752 -> 14 Sep 1752 (use 'cal(1)')

Gr_Greece 

9 Mar 1924 -> 23 Mar 1924

Gr_Hungary 

21 Oct 1587 -> 1 Nov 1587

Gr_Ireland 
Gr_Italy 
Gr_Japan 

Different authorities say:

Gr_Japan_1 

19 Dec 1872 -> 1 Jan 1873

Gr_Japan_2 

19 Dec 1892 -> 1 Jan 1893

Gr_Japan_3 

18 Dec 1918 -> 1 Jan 1919

Gr_Latvia 

1915-1918 (we take 1915)

Gr_Lithuania 

1915

Gr_Luxemburg 

14 Dec 1582 -> 25 Dec 1582

Gr_Netherlands 

(including Belgium) 1 Jan 1583

Gr_Netherlands_Groningen 

Special case of Groningen.

The Gregorian calendar was introduced twice in Groningen, first time 28 Feb 1583 was followed by 11 Mar 1583, then it has gone back to Julian in the summer of 1584 and then 13 Dec 1700 was followed by 12 Jan 1701 -- which is the date we take into account here. 13 Dec 1700 -> 12 Jan 1701

Gr_Netherlands_Gelderland 

30 Jun 1700 -> 12 Jul 1700

Gr_Netherlands_Utrecht 

(and Overijssel) 30 Nov 1700->12 Dec 1700

Gr_Netherlands_Friesland 

(and Drenthe) 31 Dec 1700 -> 12 Jan 1701

Gr_Norway 

Then part of Denmark.

Gr_Poland 
Gr_Portugal 
Gr_Romania 

31 Mar 1919 -> 14 Apr 1919

Gr_Russia 

31 Jan 1918 -> 14 Feb 1918

Gr_Scotland 
Gr_Spain 
Gr_Sweden 

Special case of Sweden.

Sweden has a curious history. Sweden decided to make a gradual change from the Julian to the Gregorian calendar. By dropping every leap year from 1700 through 1740 the eleven superfluous days would be omitted and from 1 Mar 1740 they would be in sync with the Gregorian calendar. (But in the meantime they would be in sync with nobody!)

So 1700 (which should have been a leap year in the Julian calendar) was not a leap year in Sweden. However, by mistake 1704 and 1708 became leap years. This left Sweden out of synchronisation with both the Julian and the Gregorian world, so they decided to go back to the Julian calendar. In order to do this, they inserted an extra day in 1712, making that year a double leap year! So in 1712, February had 30 days in Sweden.

Later, in 1753, Sweden changed to the Gregorian calendar by dropping 11 days like everyone else and this is what we use here. 17 Feb 1753 -> 1 Mar 1753

Gr_Switzerland 

Different cantons used different dates.

Gr_Switzerland_Catholic 

1583, 1584 or 1597 (we take 1584)

Gr_Switzerland_Protestant 

31 Dec 1700 -> 12 Jan 1701

Gr_Turkey 

1 Jan 1927

Gr_USA 
Gr_Wales 
Gr_Yugoslavia 

1919

symbolic names for the months

Enumerator:
Jan 
Feb 
Mar 
Apr 
May 
Jun 
Jul 
Aug 
Sep 
Oct 
Nov 
Dec 
Inv_Month 

Invalid month value.

Flags to be used with GetMonthName() and GetWeekDayName() functions.

Enumerator:
Name_Full 

return full name

Name_Abbr 

return abbreviated name

Time zone symbolic names.

Enumerator:
Local 

the time in the current time zone

GMT_12 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_11 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_10 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_9 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_8 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_7 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_6 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_5 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_4 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_3 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_2 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT_1 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT0 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT1 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT2 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT3 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT4 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT5 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT6 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT7 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT8 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT9 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT10 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT11 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT12 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

GMT13 

zones from GMT (= Greenwich Mean Time): they're guaranteed to be consequent numbers, so writing something like `GMT0 + offset' is safe if abs(offset) <= 12

WET 

Western Europe Time.

WEST 

Western Europe Summer Time.

CET 

Central Europe Time.

CEST 

Central Europe Summer Time.

EET 

Eastern Europe Time.

EEST 

Eastern Europe Summer Time.

MSK 

Moscow Time.

MSD 

Moscow Summer Time.

AST 

Atlantic Standard Time.

ADT 

Atlantic Daylight Time.

EST 

Eastern Standard Time.

EDT 

Eastern Daylight Saving Time.

CST 

Central Standard Time.

CDT 

Central Daylight Saving Time.

MST 

Mountain Standard Time.

MDT 

Mountain Daylight Saving Time.

PST 

Pacific Standard Time.

PDT 

Pacific Daylight Saving Time.

HST 

Hawaiian Standard Time.

AKST 

Alaska Standard Time.

AKDT 

Alaska Daylight Saving Time.

A_WST 

Western Standard Time.

A_CST 

Central Standard Time (+9.5)

A_EST 

Eastern Standard Time.

A_ESST 

Eastern Summer Time.

NZST 

Standard Time.

NZDT 

Daylight Saving Time.

UTC 

Universal Coordinated Time = the new and politically correct name for GMT.

symbolic names for the weekdays

Enumerator:
Sun 
Mon 
Tue 
Wed 
Thu 
Fri 
Sat 
Inv_WeekDay 

Invalid week day value.

Different parts of the world use different conventions for the week start.

In some countries, the week starts on Sunday, while in others -- on Monday. The ISO standard doesn't address this issue, so we support both conventions in the functions whose result depends on it (GetWeekOfYear() and GetWeekOfMonth()).

The desired behaviour may be specified by giving one of the following constants as argument to these functions.

Enumerator:
Default_First 

Sunday_First for US, Monday_First for the rest.

Monday_First 

week starts with a Monday

Sunday_First 

week starts with a Sunday

invalid value for the year

Enumerator:
Inv_Year 

Constructor & Destructor Documentation

wxDateTime::wxDateTime ( )

Default constructor.

Use one of the Set() functions to initialize the object later.

wxDateTime::wxDateTime ( const wxDateTime date)

Copy constructor.

wxDateTime::wxDateTime ( time_t  timet)

Same as Set().

wxDateTime::wxDateTime ( const struct tm &  tm)

Same as Set().

wxDateTime::wxDateTime ( double  jdn)

Same as Set().

wxDateTime::wxDateTime ( wxDateTime_t  hour,
wxDateTime_t  minute = 0,
wxDateTime_t  second = 0,
wxDateTime_t  millisec = 0 
)

Same as Set().

wxDateTime::wxDateTime ( wxDateTime_t  day,
Month  month,
int  year = Inv_Year,
wxDateTime_t  hour = 0,
wxDateTime_t  minute = 0,
wxDateTime_t  second = 0,
wxDateTime_t  millisec = 0 
)

Same as Set().

wxDateTime::wxDateTime ( const struct _SYSTEMTIME &  st)

Same as SetFromMSWSysTime.

Parameters:
stInput, Windows SYSTEMTIME reference
Since:
2.9.0
注意:
MSW only
Availability:  only available for the wxMSW port.

Member Function Documentation

wxDateTime wxDateTime::Add ( const wxDateSpan diff) const

Adds the given date span to this object.

wxDateTime wxDateTime::Add ( const wxDateSpan diff)

Adds the given date span to this object.

wxDateTime wxDateTime::Add ( const wxTimeSpan diff) const

Adds the given time span to this object.

wxDateTime& wxDateTime::Add ( const wxTimeSpan diff)

Adds the given time span to this object.

static int wxDateTime::ConvertYearToBC ( int  year) [static]

Converts the year in absolute notation (i.e.

a number which can be negative, positive or zero) to the year in BC/AD notation. For the positive years, nothing is done, but the year 0 is year 1 BC and so for other years there is a difference of 1.

This function should be used like this:

        wxDateTime dt(...);
        int y = dt.GetYear();
        printf("The year is %d%s", wxDateTime::ConvertYearToBC(y), y > 0 ? "AD" : "BC");
wxString wxDateTime::Format ( const wxString format = wxDefaultDateTimeFormat,
const TimeZone tz = Local 
) const

This function does the same as the standard ANSI C strftime(3) function (http://www.cplusplus.com/reference/clibrary/ctime/strftime.html).

Please see its description for the meaning of format parameter.

It also accepts a few wxWidgets-specific extensions: you can optionally specify the width of the field to follow using printf(3)-like syntax and the format specification "%l" can be used to get the number of milliseconds.

参照:
ParseFormat()
wxString wxDateTime::FormatDate ( ) const

Identical to calling Format() with "%x" argument (which means "preferred date representation for the current locale").

wxString wxDateTime::FormatISOCombined ( char  sep = 'T') const

Returns the combined date-time representation in the ISO 8601 format "YYYY-MM-DDTHH:MM:SS".

The sep parameter default value produces the result exactly corresponding to the ISO standard, but it can also be useful to use a space as separator if a more human-readable combined date-time representation is needed.

参照:
FormatISODate(), FormatISOTime(), ParseISOCombined()
wxString wxDateTime::FormatISODate ( ) const

This function returns the date representation in the ISO 8601 format "YYYY-MM-DD".

wxString wxDateTime::FormatISOTime ( ) const

This function returns the time representation in the ISO 8601 format "HH:MM:SS".

wxString wxDateTime::FormatTime ( ) const

Identical to calling Format() with "%X" argument (which means "preferred time representation for the current locale").

wxDateTime wxDateTime::FromTimezone ( const TimeZone tz,
bool  noDST = false 
) const

Transform the date from the given time zone to the local one.

If noDST is true, no DST adjustments will be made.

Returns:
The date in the local time zone.
static void wxDateTime::GetAmPmStrings ( wxString am,
wxString pm 
) [static]

Returns the translations of the strings AM and PM used for time formatting for the current locale.

Either of the pointers may be NULL if the corresponding value is not needed.

unsigned long wxDateTime::GetAsDOS ( ) const

Returns the date and time in DOS format.

void wxDateTime::GetAsMSWSysTime ( struct _SYSTEMTIME *  st) const

Returns the date and time in the Windows SYSTEMTIME format.

Parameters:
stOutput, pointer to Windows SYSTEMTIME
Since:
2.9.0
注意:
MSW only
Availability:  only available for the wxMSW port.
static wxDateTime wxDateTime::GetBeginDST ( int  year = Inv_Year,
Country  country = Country_Default 
) [static]

Get the beginning of DST for the given country in the given year (current one by default).

This function suffers from limitations described in the DST overview.

参照:
GetEndDST()
int wxDateTime::GetCentury ( const TimeZone tz = Local) const

Returns the century of this date.

static int wxDateTime::GetCentury ( int  year) [static]

Get the current century, i.e.

first two digits of the year, in given calendar (only Gregorian is currently supported).

static Country wxDateTime::GetCountry ( ) [static]

Returns the current default country.

The default country is used for DST calculations, for example.

参照:
SetCountry()
static Month wxDateTime::GetCurrentMonth ( Calendar  cal = Gregorian) [static]

Get the current month in given calendar (only Gregorian is currently supported).

static int wxDateTime::GetCurrentYear ( Calendar  cal = Gregorian) [static]

Get the current year in given calendar (only Gregorian is currently supported).

wxDateTime wxDateTime::GetDateOnly ( ) const

Returns the object having the same date component as this one but time of 00:00:00.

Since:
2.8.2
参照:
ResetTime()
unsigned short wxDateTime::GetDay ( const TimeZone tz = Local) const

Returns the day in the given timezone (local one by default).

unsigned short wxDateTime::GetDayOfYear ( const TimeZone tz = Local) const

Returns the day of the year (in 1-366 range) in the given timezone (local one by default).

static wxDateTime wxDateTime::GetEndDST ( int  year = Inv_Year,
Country  country = Country_Default 
) [static]

Returns the end of DST for the given country in the given year (current one by default).

参照:
GetBeginDST()
static wxString wxDateTime::GetEnglishMonthName ( Month  month,
NameFlags  flags = Name_Full 
) [static]

Return the standard English name of the given month.

This function always returns "January" or "Jan" for January, use GetMonthName() to retrieve the name of the month in the users current locale.

Parameters:
monthOne of wxDateTime::Jan, ..., wxDateTime::Dec values.
flagsEither Name_Full (default) or Name_Abbr.
参照:
GetEnglishWeekDayName()
Since:
2.9.0
static wxString wxDateTime::GetEnglishWeekDayName ( WeekDay  weekday,
NameFlags  flags = Name_Full 
) [static]

Return the standard English name of the given week day.

This function always returns "Monday" or "Mon" for Monday, use GetWeekDayName() to retrieve the name of the month in the users current locale.

Parameters:
weekdayOne of wxDateTime::Sun, ..., wxDateTime::Sat values.
flagsEither Name_Full (default) or Name_Abbr.
参照:
GetEnglishMonthName()
Since:
2.9.0
unsigned short wxDateTime::GetHour ( const TimeZone tz = Local) const

Returns the hour in the given timezone (local one by default).

double wxDateTime::GetJDN ( ) const

Synonym for GetJulianDayNumber().

double wxDateTime::GetJulianDayNumber ( ) const

Returns the JDN corresponding to this date.

Beware of rounding errors!

参照:
GetModifiedJulianDayNumber()
wxDateTime wxDateTime::GetLastMonthDay ( Month  month = Inv_Month,
int  year = Inv_Year 
) const

Returns the copy of this object to which SetToLastMonthDay() was applied.

wxDateTime wxDateTime::GetLastWeekDay ( WeekDay  weekday,
Month  month = Inv_Month,
int  year = Inv_Year 
)

Returns the copy of this object to which SetToLastWeekDay() was applied.

unsigned short wxDateTime::GetMillisecond ( const TimeZone tz = Local) const

Returns the milliseconds in the given timezone (local one by default).

unsigned short wxDateTime::GetMinute ( const TimeZone tz = Local) const

Returns the minute in the given timezone (local one by default).

double wxDateTime::GetMJD ( ) const
double wxDateTime::GetModifiedJulianDayNumber ( ) const

Returns the "Modified Julian Day Number" (MJD) which is, by definition, is equal to JDN - 2400000.5.

The MJDs are simpler to work with as the integral MJDs correspond to midnights of the dates in the Gregorian calendar and not the noons like JDN. The MJD 0 represents Nov 17, 1858.

Month wxDateTime::GetMonth ( const TimeZone tz = Local) const

Returns the month in the given timezone (local one by default).

static wxString wxDateTime::GetMonthName ( Month  month,
NameFlags  flags = Name_Full 
) [static]

Gets the full (default) or abbreviated name of the given month.

This function returns the name in the current locale, use GetEnglishMonthName() to get the untranslated name if necessary.

Parameters:
monthOne of wxDateTime::Jan, ..., wxDateTime::Dec values.
flagsEither Name_Full (default) or Name_Abbr.
参照:
GetWeekDayName()
wxDateTime wxDateTime::GetNextWeekDay ( WeekDay  weekday) const

Returns the copy of this object to which SetToNextWeekDay() was applied.

static wxDateTime_t wxDateTime::GetNumberOfDays ( Month  month,
int  year = Inv_Year,
Calendar  cal = Gregorian 
) [static]

Returns the number of days in the given month of the given year.

The only supported value for cal currently is Gregorian.

static wxDateTime_t wxDateTime::GetNumberOfDays ( int  year,
Calendar  cal = Gregorian 
) [static]

Returns the number of days in the given year.

The only supported value for cal currently is Gregorian.

wxDateTime wxDateTime::GetPrevWeekDay ( WeekDay  weekday) const

Returns the copy of this object to which SetToPrevWeekDay() was applied.

double wxDateTime::GetRataDie ( ) const

Return the Rata Die number of this date.

By definition, the Rata Die number is a date specified as the number of days relative to a base date of December 31 of the year 0. Thus January 1 of the year 1 is Rata Die day 1.

unsigned short wxDateTime::GetSecond ( const TimeZone tz = Local) const

Returns the seconds in the given timezone (local one by default).

time_t wxDateTime::GetTicks ( ) const

Returns the number of seconds since Jan 1, 1970.

An assert failure will occur if the date is not in the range covered by time_t type.

static time_t wxDateTime::GetTimeNow ( ) [static]

Returns the current time.

Tm wxDateTime::GetTm ( const TimeZone tz = Local) const

Returns broken down representation of the date and time.

static tm* wxDateTime::GetTmNow ( struct tm *  tm) [static]

Returns the current time broken down using the buffer whose address is passed to the function with tm to store the result.

static tm* wxDateTime::GetTmNow ( ) [static]

Returns the current time broken down.

Note that this function returns a pointer to a static buffer that's reused by calls to this function and certain C library functions (e.g. localtime). If there is any chance your code might be used in a multi-threaded application, you really should use GetTmNow(struct tm *) instead.

WeekDay wxDateTime::GetWeekDay ( const TimeZone tz = Local) const

Returns the week day in the given timezone (local one by default).

wxDateTime wxDateTime::GetWeekDay ( WeekDay  weekday,
int  n = 1,
Month  month = Inv_Month,
int  year = Inv_Year 
) const

Returns the copy of this object to which SetToWeekDay() was applied.

wxDateTime wxDateTime::GetWeekDayInSameWeek ( WeekDay  weekday,
WeekFlags  flags = Monday_First 
) const

Returns the copy of this object to which SetToWeekDayInSameWeek() was applied.

static wxString wxDateTime::GetWeekDayName ( WeekDay  weekday,
NameFlags  flags = Name_Full 
) [static]

Gets the full (default) or abbreviated name of the given week day.

This function returns the name in the current locale, use GetEnglishWeekDayName() to get the untranslated name if necessary.

Parameters:
weekdayOne of wxDateTime::Sun, ..., wxDateTime::Sat values.
flagsEither Name_Full (default) or Name_Abbr.
参照:
GetMonthName()
wxDateTime_t wxDateTime::GetWeekOfMonth ( WeekFlags  flags = Monday_First,
const TimeZone tz = Local 
) const

Returns the ordinal number of the week in the month (in 1-5 range).

As GetWeekOfYear(), this function supports both conventions for the week start.

wxDateTime_t wxDateTime::GetWeekOfYear ( WeekFlags  flags = Monday_First,
const TimeZone tz = Local 
) const

Returns the number of the week of the year this date is in.

The first week of the year is, according to international standards, the one containing Jan 4 or, equivalently, the first week which has Thursday in this year. Both of these definitions are the same as saying that the first week of the year must contain more than half of its days in this year. Accordingly, the week number will always be in 1-53 range (52 for non-leap years).

The function depends on the week start convention specified by the flags argument but its results for Sunday_First are not well-defined as the ISO definition quoted above applies to the weeks starting on Monday only.

int wxDateTime::GetYear ( const TimeZone tz = Local) const

Returns the year in the given timezone (local one by default).

wxDateTime wxDateTime::GetYearDay ( wxDateTime_t  yday) const

Returns the copy of this object to which SetToYearDay() was applied.

bool wxDateTime::IsBetween ( const wxDateTime t1,
const wxDateTime t2 
) const

Returns true if IsStrictlyBetween() is true or if the date is equal to one of the limit values.

参照:
IsStrictlyBetween()
int wxDateTime::IsDST ( Country  country = Country_Default) const

Returns true if the DST is applied for this date in the given country.

参照:
GetBeginDST(), GetEndDST()
static bool wxDateTime::IsDSTApplicable ( int  year = Inv_Year,
Country  country = Country_Default 
) [static]

Returns true if DST was used in the given year (the current one by default) in the given country.

bool wxDateTime::IsEarlierThan ( const wxDateTime datetime) const

Returns true if this date precedes the given one.

bool wxDateTime::IsEqualTo ( const wxDateTime datetime) const

Returns true if the two dates are strictly identical.

bool wxDateTime::IsEqualUpTo ( const wxDateTime dt,
const wxTimeSpan ts 
) const

Returns true if the date is equal to another one up to the given time interval, i.e.

if the absolute difference between the two dates is less than this interval.

bool wxDateTime::IsGregorianDate ( GregorianAdoption  country = Gr_Standard) const

Returns true if the given date is later than the date of adoption of the Gregorian calendar in the given country (and hence the Gregorian calendar calculations make sense for it).

bool wxDateTime::IsLaterThan ( const wxDateTime datetime) const

Returns true if this date is later than the given one.

static bool wxDateTime::IsLeapYear ( int  year = Inv_Year,
Calendar  cal = Gregorian 
) [static]

Returns true if the year is a leap one in the specified calendar.

This functions supports Gregorian and Julian calendars.

bool wxDateTime::IsSameDate ( const wxDateTime dt) const

Returns true if the date is the same without comparing the time parts.

bool wxDateTime::IsSameTime ( const wxDateTime dt) const

Returns true if the time is the same (although dates may differ).

bool wxDateTime::IsStrictlyBetween ( const wxDateTime t1,
const wxDateTime t2 
) const

Returns true if this date lies strictly between the two given dates.

参照:
IsBetween()
bool wxDateTime::IsValid ( ) const

Returns true if the object represents a valid time moment.

static bool wxDateTime::IsWestEuropeanCountry ( Country  country = Country_Default) [static]

This function returns true if the specified (or default) country is one of Western European ones.

It is used internally by wxDateTime to determine the DST convention and date and time formatting rules.

bool wxDateTime::IsWorkDay ( Country  country = Country_Default) const

Returns true is this day is not a holiday in the given country.

wxDateTime& wxDateTime::MakeFromTimezone ( const TimeZone tz,
bool  noDST = false 
)

Same as FromTimezone() but modifies the object in place.

wxDateTime& wxDateTime::MakeTimezone ( const TimeZone tz,
bool  noDST = false 
)

Modifies the object in place to represent the date in another time zone.

If noDST is true, no DST adjustments will be made.

wxDateTime& wxDateTime::MakeUTC ( bool  noDST = false)

This is the same as calling MakeTimezone() with the argument GMT0.

static wxDateTime wxDateTime::Now ( ) [static]

Returns the object corresponding to the current time.

例:

        wxDateTime now = wxDateTime::Now();
        printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str());
注:
This function is accurate up to seconds. UNow() can be used if better precision is required.
参照:
Today()
wxDateTime& wxDateTime::operator+= ( const wxTimeSpan diff)

Adds the given time span to this object.

wxDateTime& wxDateTime::operator+= ( const wxDateSpan diff)

Adds the given date span to this object.

wxDateTime& wxDateTime::operator-= ( const wxDateSpan diff)

Subtracts the given date span from this object.

wxDateTime& wxDateTime::operator-= ( const wxTimeSpan diff)

Subtracts the given time span from this object.

wxDateTime& wxDateTime::operator= ( const struct tm &  tm)

Same as Set().

wxDateTime& wxDateTime::operator= ( time_t  timet)

Same as Set().

bool wxDateTime::ParseDate ( const wxString date,
wxString::const_iterator *  end 
)

This function is like ParseDateTime(), but it only allows the date to be specified.

It is thus less flexible then ParseDateTime(), but also has less chances to misinterpret the user input.

See ParseFormat() for the description of function parameters and return value.

参照:
Format()
bool wxDateTime::ParseDateTime ( const wxString datetime,
wxString::const_iterator *  end 
)

Parses the string datetime containing the date and time in free format.

This function tries as hard as it can to interpret the given string as date and time. Unlike ParseRfc822Date(), it will accept anything that may be accepted and will only reject strings which cannot be parsed in any way at all. Notice that the function will fail if either date or time part is present but not both, use ParseDate() or ParseTime() to parse strings containing just the date or time component.

See ParseFormat() for the description of function parameters and return value.

bool wxDateTime::ParseFormat ( const wxString date,
const wxString format,
const wxDateTime dateDef,
wxString::const_iterator *  end 
)

This function parses the string date according to the given format.

The system strptime(3) function is used whenever available, but even if it is not, this function is still implemented, although support for locale-dependent format specifiers such as "%c", "%x" or "%X" may not be perfect and GNU extensions such as "%z" and "%Z" are not implemented. This function does handle the month and weekday names in the current locale on all platforms, however.

Please see the description of the ANSI C function strftime(3) for the syntax of the format string.

The dateDef parameter is used to fill in the fields which could not be determined from the format string. For example, if the format is "%d" (the day of the month), the month and the year are taken from dateDef. If it is not specified, Today() is used as the default date.

Example of using this function:

            wxDateTime dt;
            wxString str = "...";
            wxString::const_iterator end;
            if ( !dt.ParseFormat(str, "%Y-%m-%d", &end) )
                ... parsing failed ...
            else if ( end == str.end() )
                ... entire string parsed ...
            else
                ... wxString(end, str.end()) left over ...
Parameters:
dateThe string to be parsed.
formatstrptime()-like format string.
dateDefUsed to fill in the date components not specified in the date string.
endWill be filled with the iterator pointing to the location where the parsing stopped if the function returns true. If the entire string was consumed, it is set to date.end(). Notice that this argument must be non-NULL.
Returns:
true if at least part of the string was parsed successfully, false otherwise.
参照:
Format()
bool wxDateTime::ParseFormat ( const wxString date,
const wxString format,
wxString::const_iterator *  end 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool wxDateTime::ParseFormat ( const wxString date,
wxString::const_iterator *  end 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

bool wxDateTime::ParseISOCombined ( const wxString date,
char  sep = 'T' 
)

This function parses the string containing the date and time in ISO 8601 combined format "YYYY-MM-DDTHH:MM:SS".

The separator between the date and time parts must be equal to sep for the function to succeed.

Returns:
true if the entire string was parsed successfully, false otherwise.
bool wxDateTime::ParseISODate ( const wxString date)

This function parses the date in ISO 8601 format "YYYY-MM-DD".

Returns:
true if the entire string was parsed successfully, false otherwise.
bool wxDateTime::ParseISOTime ( const wxString date)

This function parses the time in ISO 8601 format "HH:MM:SS".

Returns:
true if the entire string was parsed successfully, false otherwise.
bool wxDateTime::ParseRfc822Date ( const wxString date,
wxString::const_iterator *  end 
)

Parses the string date looking for a date formatted according to the RFC 822 in it.

The exact description of this format may, of course, be found in the RFC (section 5), but, briefly, this is the format used in the headers of Internet email messages and one of the most common strings expressing date in this format may be something like "Sat, 18 Dec 1999 00:48:30 +0100".

Returns NULL if the conversion failed, otherwise return the pointer to the character immediately following the part of the string which could be parsed. If the entire string contains only the date in RFC 822 format, the returned pointer will be pointing to a NUL character.

This function is intentionally strict, it will return an error for any string which is not RFC 822 compliant. If you need to parse date formatted in more free ways, you should use ParseDateTime() or ParseDate() instead.

See ParseFormat() for the description of function parameters and return value.

bool wxDateTime::ParseTime ( const wxString time,
wxString::const_iterator *  end 
)

This functions is like ParseDateTime(), but only allows the time to be specified in the input string.

See ParseFormat() for the description of function parameters and return value.

wxDateTime& wxDateTime::ResetTime ( )

Reset time to midnight (00:00:00) without changing the date.

wxDateTime& wxDateTime::Set ( time_t  timet)

Constructs the object from timet value holding the number of seconds since Jan 1, 1970.

wxDateTime& wxDateTime::Set ( const Tm tm)

Sets the date and time from the broken down representation in the wxDateTime::Tm structure.

wxDateTime& wxDateTime::Set ( double  jdn)

Sets the date from the so-called Julian Day Number.

By definition, the Julian Day Number, usually abbreviated as JDN, of a particular instant is the fractional number of days since 12 hours Universal Coordinated Time (Greenwich mean noon) on January 1 of the year -4712 in the Julian proleptic calendar.

wxDateTime& wxDateTime::Set ( wxDateTime_t  day,
Month  month,
int  year = Inv_Year,
wxDateTime_t  hour = 0,
wxDateTime_t  minute = 0,
wxDateTime_t  second = 0,
wxDateTime_t  millisec = 0 
)

Sets the date and time from the parameters.

wxDateTime& wxDateTime::Set ( wxDateTime_t  hour,
wxDateTime_t  minute = 0,
wxDateTime_t  second = 0,
wxDateTime_t  millisec = 0 
)

Sets the date to be equal to Today() and the time from supplied parameters.

wxDateTime& wxDateTime::Set ( const struct tm &  tm)

Sets the date and time from the broken down representation in the standard tm structure.

static void wxDateTime::SetCountry ( Country  country) [static]

Sets the country to use by default.

This setting influences the DST calculations, date formatting and other things.

参照:
GetCountry()
wxDateTime& wxDateTime::SetDay ( unsigned short  day)

Sets the day without changing other date components.

wxDateTime& wxDateTime::SetFromDOS ( unsigned long  ddt)

Sets the date from the date and time in DOS format.

wxDateTime& wxDateTime::SetFromMSWSysTime ( const struct _SYSTEMTIME &  st)

Initialize using the Windows SYSTEMTIME structure.

Parameters:
stInput, Windows SYSTEMTIME reference
Since:
2.9.0
注意:
MSW only
Availability:  only available for the wxMSW port.
wxDateTime& wxDateTime::SetHour ( unsigned short  hour)

Sets the hour without changing other date components.

wxDateTime& wxDateTime::SetMillisecond ( unsigned short  millisecond)

Sets the millisecond without changing other date components.

wxDateTime& wxDateTime::SetMinute ( unsigned short  minute)

Sets the minute without changing other date components.

wxDateTime& wxDateTime::SetMonth ( Month  month)

Sets the month without changing other date components.

wxDateTime& wxDateTime::SetSecond ( unsigned short  second)

Sets the second without changing other date components.

wxDateTime& wxDateTime::SetToCurrent ( )

Sets the date and time of to the current values.

Same as assigning the result of Now() to this object.

wxDateTime& wxDateTime::SetToLastMonthDay ( Month  month = Inv_Month,
int  year = Inv_Year 
)

Sets the date to the last day in the specified month (the current one by default).

Returns:
The reference to the modified object itself.
bool wxDateTime::SetToLastWeekDay ( WeekDay  weekday,
Month  month = Inv_Month,
int  year = Inv_Year 
)

The effect of calling this function is the same as of calling SetToWeekDay(-1, weekday, month, year).

The date will be set to the last weekday in the given month and year (the current ones by default). Always returns true.

wxDateTime& wxDateTime::SetToNextWeekDay ( WeekDay  weekday)

Sets the date so that it will be the first weekday following the current date.

Returns:
The reference to the modified object itself.
wxDateTime& wxDateTime::SetToPrevWeekDay ( WeekDay  weekday)

Sets the date so that it will be the last weekday before the current date.

Returns:
The reference to the modified object itself.
bool wxDateTime::SetToWeekDay ( WeekDay  weekday,
int  n = 1,
Month  month = Inv_Month,
int  year = Inv_Year 
)

Sets the date to the n-th weekday in the given month of the given year (the current month and year are used by default).

The parameter n may be either positive (counting from the beginning of the month) or negative (counting from the end of it).

For example, SetToWeekDay(2, wxDateTime::Wed) will set the date to the second Wednesday in the current month and SetToWeekDay(-1, wxDateTime::Sun) will set the date to the last Sunday in the current month.

Returns:
true if the date was modified successfully, false otherwise meaning that the specified date doesn't exist.
wxDateTime& wxDateTime::SetToWeekDayInSameWeek ( WeekDay  weekday,
WeekFlags  flags = Monday_First 
)

Adjusts the date so that it will still lie in the same week as before, but its week day will be the given one.

Returns:
The reference to the modified object itself.
static wxDateTime wxDateTime::SetToWeekOfYear ( int  year,
wxDateTime_t  numWeek,
WeekDay  weekday = Mon 
) [static]

Set the date to the given weekday in the week number numWeek of the given year .

The number should be in range 1-53.

Note that the returned date may be in a different year than the one passed to this function because both the week 1 and week 52 or 53 (for leap years) contain days from different years. See GetWeekOfYear() for the explanation of how the year weeks are counted.

wxDateTime& wxDateTime::SetToYearDay ( wxDateTime_t  yday)

Sets the date to the day number yday in the same year (i.e., unlike the other functions, this one does not use the current year).

The day number should be in the range 1-366 for the leap years and 1-365 for the other ones.

Returns:
The reference to the modified object itself.
wxDateTime& wxDateTime::SetYear ( int  year)

Sets the year without changing other date components.

wxTimeSpan wxDateTime::Subtract ( const wxDateTime dt) const

Subtracts another date from this one and returns the difference between them as a wxTimeSpan.

wxDateTime& wxDateTime::Subtract ( const wxDateSpan diff)

Subtracts the given date span from this object.

wxDateTime wxDateTime::Subtract ( const wxTimeSpan diff) const

Subtracts the given time span from this object.

wxDateTime wxDateTime::Subtract ( const wxDateSpan diff) const

Subtracts the given date span from this object.

wxDateTime& wxDateTime::Subtract ( const wxTimeSpan diff)

Subtracts the given time span from this object.

static wxDateTime wxDateTime::Today ( ) [static]

Returns the object corresponding to the midnight of the current day (i.e.

the same as Now(), but the time part is set to 0).

参照:
Now()
wxDateTime wxDateTime::ToTimezone ( const TimeZone tz,
bool  noDST = false 
) const

Transform the date to the given time zone.

If noDST is true, no DST adjustments will be made.

Returns:
The date in the new time zone.
wxDateTime wxDateTime::ToUTC ( bool  noDST = false) const

This is the same as calling ToTimezone() with the argument GMT0.

static wxDateTime wxDateTime::UNow ( ) [static]

Returns the object corresponding to the current UTC time including the milliseconds.

Notice that unlike Now(), this method creates a wxDateTime object corresponding to UTC, not local, time.

参照:
Now(), wxGetUTCTimeMillis()
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines