/////////////////////////////////////////////////////////////////////////////
// Name: datetime.h
-// Purpose: documentation for wxDateTime class
+// Purpose: interface of wxDateTime
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
@library{wxbase}
@category{data}
- @seealso
- @ref overview_wxdatetimeoverview "Date classes overview", wxTimeSpan,
+ @stdobjects
+ ::wxDefaultDateTime
+
+ @see @ref overview_wxdatetimeoverview "Date classes overview", wxTimeSpan,
wxDateSpan, wxCalendarCtrl
*/
class wxDateTime
Same as @ref setdate() Set
*/
wxDateTime(wxDateTime_t day, Month month = Inv_Month,
- int Inv_Year, wxDateTime_t hour = 0,
+ int year = Inv_Year, wxDateTime_t hour = 0,
wxDateTime_t minute = 0,
wxDateTime_t second = 0,
wxDateTime_t millisec = 0);
some more complicated calculations to find the answer are under the
@ref overview_datetimecalculations "Calendar calculations" section.
IsValid()
-
+
GetTicks()
-
+
GetCentury()
-
+
GetYear()
-
+
GetMonth()
-
+
GetDay()
-
+
GetWeekDay()
-
+
GetHour()
-
+
GetMinute()
-
+
GetSecond()
-
+
GetMillisecond()
-
+
GetDayOfYear()
-
+
GetWeekOfYear()
-
+
GetWeekOfMonth()
-
+
GetYearDay()
-
+
IsWorkDay()
-
+
IsGregorianDate()
-
+
GetAsDOS()
*/
@ref getmodifiedjuliandaynumber() MJD or
@ref getratadie() "Rata Die number" from it.
@ref wxdatetimejdn() "wxDateTime(double jdn)"
-
+
@ref setjdn() "Set(double jdn)"
-
+
GetJulianDayNumber()
-
+
GetJDN()
-
+
GetModifiedJulianDayNumber()
-
+
GetMJD()
-
+
GetRataDie()
*/
All (non-const) functions in this section don't modify the time part of the
wxDateTime -- they only work with the date part of it.
SetToWeekDayInSameWeek()
-
+
GetWeekDayInSameWeek()
-
+
SetToNextWeekDay()
-
+
GetNextWeekDay()
-
+
SetToPrevWeekDay()
-
+
GetPrevWeekDay()
-
+
SetToWeekDay()
-
+
@ref wxDateTime::getweekday2 GetWeekDay
-
+
SetToLastWeekDay()
-
+
GetLastWeekDay()
-
+
SetToWeekOfYear()
-
+
SetToLastMonthDay()
-
+
GetLastMonthDay()
-
+
SetToYearDay()
-
+
GetYearDay()
*/
should use IsValid() method to check that the
values were correct as constructors can not return an error code.
@ref wxdatetimedef() wxDateTime
-
+
@ref wxdatetimetimet() wxDateTime(time_t)
-
+
@ref wxdatetimetm() "wxDateTime(struct tm)"
-
+
@ref wxdatetimejdn() "wxDateTime(double jdn)"
-
+
@ref wxdatetimetime() "wxDateTime(h, m, s, ms)"
-
+
@ref wxdatetimedate() "wxDateTime(day, mon, year, h, m, s, ms)"
-
+
SetToCurrent()
-
+
@ref settimet() Set(time_t)
-
+
@ref settm() "Set(struct tm)"
-
+
@ref setjdn() "Set(double jdn)"
-
+
@ref settime() "Set(h, m, s, ms)"
-
+
@ref setdate() "Set(day, mon, year, h, m, s, ms)"
-
+
@ref setfromdos() "SetFromDOS(unsigned long ddt)"
-
+
ResetTime()
-
+
SetYear()
-
+
SetMonth()
-
+
@ref setdate() SetDay
-
+
SetHour()
-
+
SetMinute()
-
+
SetSecond()
-
+
SetMillisecond()
-
+
@ref operatoreqtimet() operator=(time_t)
-
+
@ref operatoreqtm() "operator=(struct tm)"
*/
static int ConvertYearToBC(int year);
/**
- These functions carry out arithmetics on the wxDateTime
+ 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.
modifies the object to which it is applied. The operators -= and += are
defined to be equivalent to the second forms of these functions.
@ref addts() Add(wxTimeSpan)
-
+
@ref addds() Add(wxDateSpan)
-
+
@ref subtractts() Subtract(wxTimeSpan)
-
+
@ref subtractds() Subtract(wxDateSpan)
-
+
@ref subtractdt() Subtract(wxDateTime)
-
+
@ref addts() oparator+=(wxTimeSpan)
-
+
@ref addds() oparator+=(wxDateSpan)
-
+
@ref subtractts() oparator-=(wxTimeSpan)
-
+
@ref subtractds() oparator-=(wxDateSpan)
*/
There are several function to allow date comparison. To supplement them, a few
global operators , etc taking wxDateTime are defined.
IsEqualTo()
-
+
IsEarlierThan()
-
+
IsLaterThan()
-
+
IsStrictlyBetween()
-
+
IsBetween()
-
+
IsSameDate()
-
+
IsSameTime()
-
+
IsEqualUpTo()
*/
It also accepts a few wxWidgets-specific extensions: you can optionally specify
the width of the field to follow using @c printf(3)-like syntax and the
format specification @c %l can be used to get the number of milliseconds.
-
+
@see ParseFormat()
*/
wxString Format(const wxChar* format = wxDefaultDateTimeFormat,
result exactly corresponding to the ISO standard, but it can also be useful to
use a space as seprator if a more human-readable combined date-time
representation is needed.
-
+
@see FormatISODate(), FormatISOTime(),
ParseISOCombined()
*/
DOS
format.
*/
- unsigned long GetAsDOS() const;
+ long unsigned int GetAsDOS() const;
/**
Get the beginning of DST for the given country in the given year (current one
by default). This function suffers from limitations described in
@ref overview_tdatedst "DST overview".
-
+
@see GetEndDST()
*/
static wxDateTime GetBeginDST(int year = Inv_Year,
/**
Returns the current default country. The default country is used for DST
calculations, for example.
-
+
@see SetCountry()
*/
static Country GetCountry();
/**
Returns the object having the same date component as this one but time of
00:00:00.
- This function is new since wxWidgets version 2.8.2
-
+
+ @wxsince{2.8.2}
+
@see ResetTime()
*/
wxDateTime GetDateOnly() const;
/**
Returns the day in the given timezone (local one by default).
*/
- wxDateTime_t GetDay(const TimeZone& tz = Local) const;
+ short unsigned int GetDay(const TimeZone& tz = Local) const;
/**
Returns the day of the year (in 1...366 range) in the given timezone
(local one by default).
*/
- wxDateTime_t GetDayOfYear(const TimeZone& tz = Local) const;
+ short unsigned int GetDayOfYear(const TimeZone& tz = Local) const;
/**
Returns the end of DST for the given country in the given year (current one by
default).
-
+
@see GetBeginDST()
*/
static wxDateTime GetEndDST(int year = Inv_Year,
/**
Returns the hour in the given timezone (local one by default).
*/
- wxDateTime_t GetHour(const TimeZone& tz = Local) const;
+ short unsigned int GetHour(const TimeZone& tz = Local) const;
/**
Synonym for GetJulianDayNumber().
/**
Returns the @ref setjdn() JDN corresponding to this date. Beware
of rounding errors!
-
+
@see GetModifiedJulianDayNumber()
*/
double GetJulianDayNumber() const;
/**
Returns the milliseconds in the given timezone (local one by default).
*/
- wxDateTime_t GetMillisecond(const TimeZone& tz = Local) const;
+ short unsigned int GetMillisecond(const TimeZone& tz = Local) const;
/**
Returns the minute in the given timezone (local one by default).
*/
- wxDateTime_t GetMinute(const TimeZone& tz = Local) const;
+ short unsigned int GetMinute(const TimeZone& tz = Local) const;
/**
Returns the @e Modified Julian Day Number (MJD) which is, by definition,
/**
Gets the full (default) or abbreviated (specify @c Name_Abbr name of the
given month.
-
+
@see GetWeekDayName()
*/
static wxString GetMonthName(Month month,
/**
Returns the seconds in the given timezone (local one by default).
*/
- wxDateTime_t GetSecond(const TimeZone& tz = Local) const;
+ short unsigned int GetSecond(const TimeZone& tz = Local) const;
/**
Returns the number of seconds since Jan 1, 1970. An assert failure will occur
/**
Gets the full (default) or abbreviated (specify @c Name_Abbr name of the
given week day.
-
+
@see GetMonthName()
*/
static wxString GetWeekDayName(WeekDay weekday,
Returns the copy of this object to which
SetToYearDay() was applied.
*/
- wxDateTime GetYearDay(wxDateTime_t yday) const;
+ wxDateTime GetYearDay(short unsigned int) const;
/**
Returns @true if IsStrictlyBetween()
is @true or if the date is equal to one of the limit values.
-
+
@see IsStrictlyBetween()
*/
bool IsBetween(const wxDateTime& t1, const wxDateTime& t2) const;
/**
Returns @true if this date lies strictly between the two others,
-
+
@see IsBetween()
*/
bool IsStrictlyBetween(const wxDateTime& t1,
This is the same as calling MakeTimezone() with
the argument @c GMT0.
*/
- wxDateTime MakeUTC(bool noDST = false);
+ wxDateTime& MakeUTC(bool noDST = false);
/**
Returns the object corresponding to the current time.
Example:
-
+
Note that this function is accurate up to second:
UNow() should be used for better precision
(but it is less efficient and might not be available on all platforms).
-
+
@see Today()
*/
static wxDateTime Now();
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.
ParseFormat()
-
+
ParseDateTime()
-
+
ParseDate()
-
+
ParseTime()
-
+
ParseISODate()
-
+
ParseISOTime()
-
+
ParseISOCombined()
-
+
wxDateTime::ParseRfc822Date
-
+
Format()
-
+
FormatDate()
-
+
FormatTime()
-
+
FormatISOCombined()
-
+
FormatISODate()
-
+
FormatISOTime()
*/
/**
Reset time to midnight (00:00:00) without changing the date.
*/
- wxDateTime ResetTime();
+ wxDateTime& ResetTime();
/**
Sets the date and time from the parameters.
calculations, date formatting and other things.
The possible values for @a country parameter are enumerated in
@ref overview_wxdatetime "wxDateTime constants section".
-
+
@see GetCountry()
*/
static void SetCountry(Country country);
/**
Sets the day without changing other date components.
*/
- wxDateTime SetDay(wxDateTime_t day);
+ wxDateTime& SetDay(short unsigned int);
/**
Sets the date from the date and time in
/**
Sets the hour without changing other date components.
*/
- wxDateTime SetHour(wxDateTime_t hour);
+ wxDateTime& SetHour(short unsigned int);
/**
Sets the millisecond without changing other date components.
*/
- wxDateTime SetMillisecond(wxDateTime_t millisecond);
+ wxDateTime& SetMillisecond(short unsigned int);
/**
Sets the minute without changing other date components.
*/
- wxDateTime SetMinute(wxDateTime_t minute);
+ wxDateTime& SetMinute(short unsigned int);
/**
Sets the month without changing other date components.
*/
- wxDateTime SetMonth(Month month);
+ wxDateTime& SetMonth(Month month);
/**
Sets the second without changing other date components.
*/
- wxDateTime SetSecond(wxDateTime_t second);
+ wxDateTime& SetSecond(short unsigned int);
/**
Sets the date and time of to the current values. Same as assigning the result
of Now() to this object.
*/
- wxDateTime SetToCurrent();
+ wxDateTime& SetToCurrent();
/**
Sets the date to the last day in the specified month (the current one by
date.
Returns the reference to the modified object itself.
*/
- wxDateTime SetToNextWeekDay(WeekDay weekday);
+ wxDateTime& SetToNextWeekDay(WeekDay weekday);
/**
Sets the date so that it will be the last @a weekday before the current
date.
Returns the reference to the modified object itself.
*/
- wxDateTime SetToPrevWeekDay(WeekDay weekday);
+ wxDateTime& SetToPrevWeekDay(WeekDay weekday);
/**
Sets the date to the @e n-th @a weekday in the given month of the given
the other ones.
Returns the reference to the modified object itself.
*/
- wxDateTime SetToYearDay(wxDateTime_t yday);
+ wxDateTime& SetToYearDay(short unsigned int);
/**
Sets the year without changing other date components.
*/
- wxDateTime SetYear(int year);
+ wxDateTime& SetYear(int year);
/**
For convenience, all static functions are collected here. These functions
Please note that although several function accept an extra @e Calendar
parameter, it is currently ignored as only the Gregorian calendar is
supported. Future versions will support other calendars.
-
+
SetCountry()
-
+
GetCountry()
-
+
IsWestEuropeanCountry()
-
+
GetCurrentYear()
-
+
ConvertYearToBC()
-
+
GetCurrentMonth()
-
+
IsLeapYear()
-
+
@ref getcenturystatic() GetCentury
-
+
GetNumberOfDays()
-
+
GetNumberOfDays()
-
+
GetMonthName()
-
+
GetWeekDayName()
-
+
GetAmPmStrings()
-
+
IsDSTApplicable()
-
+
GetBeginDST()
-
+
GetEndDST()
-
+
Now()
-
+
UNow()
-
+
Today()
*/
Please see the @ref overview_tdatetimezones "time zone overview" for more
information about time zones. Normally, these functions should be rarely used.
FromTimezone()
-
+
ToTimezone()
-
+
MakeTimezone()
-
+
MakeFromTimezone()
-
+
ToUTC()
-
+
MakeUTC()
-
+
GetBeginDST()
-
+
GetEndDST()
-
+
IsDST()
*/
/**
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).
-
+
@see Now()
*/
static wxDateTime Today();
Returns the object corresponding to the current time including the
milliseconds if a function to get time with such precision is available on the
current platform (supported under most Unices and Win32).
-
+
@see Now()
*/
static wxDateTime UNow();
wxDateTime operator(const struct tm& tm);
};
+/**
+ Global instance of an empty wxDateTime object.
+
+ @todo wouldn't be better to rename it wxNullDateTime as for the rest of wx global objects
+ which are initialized to an empty value?
+*/
+wxDateTime wxDefaultDateTime;
+
+
/**
@class wxDateTimeWorkDays
};
+
/**
@class wxDateSpan
@wxheader{datetime.h}
@library{wxbase}
@category{data}
- @seealso
- @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime
+ @see @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime
*/
class wxDateSpan
{
/**
Returns a date span object corresponding to one day.
-
+
@see Days()
*/
static wxDateSpan Day();
/**
Returns a date span object corresponding to the given number of days.
-
+
@see Day()
*/
static wxDateSpan Days(int days);
/**
Returns the number of days (only, that it not counting the weeks component!)
in this date span.
-
+
@see GetTotalDays()
*/
int GetDays() const;
/**
Returns the combined number of days in this date span, counting both weeks and
days. It still doesn't take neither months nor years into the account.
-
+
@see GetWeeks(), GetDays()
*/
int GetTotalDays() const;
/**
Returns the number of weeks in this date span.
-
+
@see GetTotalDays()
*/
int GetWeeks() const;
/**
Returns a date span object corresponding to one month.
-
+
@see Months()
*/
static wxDateSpan Month();
/**
Returns a date span object corresponding to the given number of months.
-
+
@see Month()
*/
static wxDateSpan Months(int mon);
//@{
/**
Changes the sign of this date span.
-
+
@see Negate()
*/
wxDateSpan Neg();
/**
Returns the date span with the opposite sign.
-
+
@see Neg()
*/
wxDateSpan Negate() const;
Sets the number of days (without modifying any other components) in this date
span.
*/
- wxDateSpan SetDays(int n);
+ wxDateSpan& SetDays(int n);
/**
Sets the number of months (without modifying any other components) in this
date span.
*/
- wxDateSpan SetMonths(int n);
+ wxDateSpan& SetMonths(int n);
/**
Sets the number of weeks (without modifying any other components) in this date
span.
*/
- wxDateSpan SetWeeks(int n);
+ wxDateSpan& SetWeeks(int n);
/**
Sets the number of years (without modifying any other components) in this date
span.
*/
- wxDateSpan SetYears(int n);
+ wxDateSpan& SetYears(int n);
//@{
/**
/**
Returns a date span object corresponding to one week.
-
+
@see Weeks()
*/
static wxDateSpan Week();
/**
Returns a date span object corresponding to the given number of weeks.
-
+
@see Week()
*/
static wxDateSpan Weeks(int weeks);
/**
Returns a date span object corresponding to one year.
-
+
@see Years()
*/
static wxDateSpan Year();
/**
Returns a date span object corresponding to the given number of years.
-
+
@see Year()
*/
static wxDateSpan Years(int years);
/**
Returns @true if this date span is different from the other one.
*/
- bool operator!=(wxDateSpan& other) const;
+ bool operator!=(const wxDateSpan&) const;
/**
Returns @true if this date span is equal to the other one. Two date spans
are considered equal if and only if they have the same number of years and
months and the same total number of days (counting both days and weeks).
*/
- bool operator==(wxDateSpan& other) const;
+ bool operator==(const wxDateSpan&) const;
};
+
/**
@class wxTimeSpan
@wxheader{datetime.h}
@library{wxbase}
@category{data}
- @seealso
- @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime
+ @see @ref overview_wxdatetimeoverview "Date classes overview", wxDateTime
*/
class wxTimeSpan
{
/**
GetSeconds()
-
+
GetMinutes()
-
+
GetHours()
-
+
GetDays()
-
+
GetWeeks()
-
+
GetValue()
*/
/**
Returns the string containing the formatted representation of the time span.
The following format specifiers are allowed after %:
-
+
H
-
+
number of @b Hours
-
+
M
-
+
number of @b Minutes
-
+
S
-
+
number of @b Seconds
-
+
l
-
+
number of mi@b lliseconds
-
+
D
-
+
number of @b Days
-
+
E
-
+
number of w@b Eeks
-
+
%
-
+
the percent character
-
+
Note that, for example, the number of hours in the description above is not
well defined: it can be either the total number of hours (for example, for a
time span of 50 hours this would be 50) or just the hour part of the time
The same applies to all other format specifiers: if they follow a specifier of
larger unit, only the rest part is taken, otherwise the full value is used.
*/
- wxString Format(const wxChar* format = wxDefaultTimeSpanFormat);
+ wxString Format(const wxString& = wxDefaultTimeSpanFormat) const;
/**
Format()
/**
Add()
-
+
Subtract()
-
+
Multiply()
-
+
Negate()
-
+
Neg()
-
+
Abs()
*/
/**
Milliseconds()
-
+
Millisecond()
-
+
Seconds()
-
+
Second()
-
+
Minutes()
-
+
Minute()
-
+
Hours()
-
+
Hour()
-
+
Days()
-
+
Day()
-
+
Weeks()
-
+
Week()
*/
/**
IsNull()
-
+
IsPositive()
-
+
IsNegative()
-
+
IsEqualTo()
-
+
IsLongerThan()
-
+
IsShorterThan()
*/
};
+
/**
@class wxDateTimeHolidayAuthority
@wxheader{datetime.h}
public:
};
+