git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31439
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
\end{verbatim}
Date calculations often depend on the country and wxDateTime allows to set the
\end{verbatim}
Date calculations often depend on the country and wxDateTime allows to set the
-country whose conventions should be used using
+country whose conventions should be used using
\helpref{SetCountry}{wxdatetimesetcountry}. It takes one of the following
values as parameter:
\helpref{SetCountry}{wxdatetimesetcountry}. It takes one of the following
values as parameter:
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
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 (\helpref{GetWeekOfYear}{wxdatetimegetweekofyear} and
+the functions whose result depends on it (\helpref{GetWeekOfYear}{wxdatetimegetweekofyear} and
\helpref{GetWeekOfMonth}{wxdatetimegetweekofmonth}).
The desired behvaiour may be specified by giving one of the following
\helpref{GetWeekOfMonth}{wxdatetimegetweekofmonth}).
The desired behvaiour may be specified by giving one of the following
parameter, it is currently ignored as only the Gregorian calendar is
supported. Future versions will support other calendars.
parameter, it is currently ignored as only the Gregorian calendar is
supported. Future versions will support other calendars.
-\pythonnote{These methods are standalone functions named
+\pythonnote{These methods are standalone functions named
{\tt wxDateTime\_<StaticMethodName>} in wxPython.}
\helpref{SetCountry}{wxdatetimesetcountry}\\
{\tt wxDateTime\_<StaticMethodName>} in wxPython.}
\helpref{SetCountry}{wxdatetimesetcountry}\\
\membersection{Accessors}\label{datetimeaccessors}
Here are the trivial accessors. Other functions, which might have to perform
\membersection{Accessors}\label{datetimeaccessors}
Here are the trivial accessors. Other functions, which might have to perform
-some more complicated calculations to find the answer are under the
+some more complicated calculations to find the answer are under the
\helpref{Calendar calculations}{datetimecalculations} section.
\helpref{IsValid}{wxdatetimeisvalid}\\
\helpref{Calendar calculations}{datetimecalculations} section.
\helpref{IsValid}{wxdatetimeisvalid}\\
These functions convert wxDateTime objects to and from text. The
conversions to text are mostly trivial: you can either do it using the default
These 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 (
-\helpref{FormatDate}{wxdatetimeformatdate} and
+date and time representations for the current locale (
+\helpref{FormatDate}{wxdatetimeformatdate} and
\helpref{FormatTime}{wxdatetimeformattime}), using the international standard
\helpref{FormatTime}{wxdatetimeformattime}), using the international standard
-representation defined by ISO 8601 (
-\helpref{FormatISODate}{wxdatetimeformatisodate} and
+representation defined by ISO 8601 (
+\helpref{FormatISODate}{wxdatetimeformatisodate} and
\helpref{FormatISOTime}{wxdatetimeformatisotime}) or by specifying any format
at all and using \helpref{Format}{wxdatetimeformat} directly.
The conversions from text are more interesting, as there are much more
\helpref{FormatISOTime}{wxdatetimeformatisotime}) or by specifying any format
at all and using \helpref{Format}{wxdatetimeformat} 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
+possibilities to care about. The simplest cases can be taken care of with
\helpref{ParseFormat}{wxdatetimeparseformat} which can parse any date in the
given (rigid) format. \helpref{ParseRfc822Date}{wxdatetimeparserfc822date} 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
\helpref{ParseFormat}{wxdatetimeparseformat} which can parse any date in the
given (rigid) format. \helpref{ParseRfc822Date}{wxdatetimeparserfc822date} 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 can not be described with {\tt strptime(3)}-like format strings used by
+format can not be described with {\tt strptime(3)}-like format strings used by
\helpref{Format}{wxdatetimeformat}, hence the need for a separate function.
\helpref{Format}{wxdatetimeformat}, hence the need for a separate function.
-But the most interesting functions are
-\helpref{ParseTime}{wxdatetimeparsetime},
-\helpref{ParseDate}{wxdatetimeparsedate} and
+But the most interesting functions are
+\helpref{ParseTime}{wxdatetimeparsetime},
+\helpref{ParseDate}{wxdatetimeparsedate} and
\helpref{ParseDateTime}{wxdatetimeparsedatetime}. They try to parse the date
ans 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, \helpref{ParseDateTime}{wxdatetimeparsedatetime} can
\helpref{ParseDateTime}{wxdatetimeparsedatetime}. They try to parse the date
ans 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, \helpref{ParseDateTime}{wxdatetimeparsedatetime} can
-parse the strings such as {\tt "tomorrow"}, {\tt "March first"} and even
+parse the strings such as {\tt "tomorrow"}, {\tt "March first"} and even
{\tt "next Sunday"}.
\helpref{ParseRfc822Date}{wxdatetimeparserfc822date}\\
{\tt "next Sunday"}.
\helpref{ParseRfc822Date}{wxdatetimeparserfc822date}\\
printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str());
\end{verbatim}
printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str());
\end{verbatim}
-Note that this function is accurate up to second:
+Note that this function is accurate up to second:
\helpref{wxDateTime::UNow}{wxdatetimeunow} should be used for better precision
(but it is less efficient and might not be available on all platforms).
\helpref{wxDateTime::UNow}{wxdatetimeunow} should be used for better precision
(but it is less efficient and might not be available on all platforms).
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimedate}
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimedate}
-\func{wxDateTime\&}{wxDateTime}{\param{wxDateTime\_t }{day}, \param{Month }{month = Inv\_Month}, \param{int}{ Inv\_Year},
+\func{wxDateTime\&}{wxDateTime}{\param{wxDateTime\_t }{day}, \param{Month }{month = Inv\_Month}, \param{int}{ Inv\_Year},
\param{wxDateTime\_t }{hour = 0}, \param{wxDateTime\_t }{minute = 0}, \param{wxDateTime\_t }{second = 0}, \param{wxDateTime\_t }{millisec = 0}}
Same as \helpref{Set}{wxdatetimesetdate}
\param{wxDateTime\_t }{hour = 0}, \param{wxDateTime\_t }{minute = 0}, \param{wxDateTime\_t }{second = 0}, \param{wxDateTime\_t }{millisec = 0}}
Same as \helpref{Set}{wxdatetimesetdate}
always be in $1\ldots53$ range ($52$ for non leap years).
The function depends on the \helpref{week start}{wxdatetime} convention
always be in $1\ldots53$ range ($52$ for non leap years).
The function depends on the \helpref{week start}{wxdatetime} convention
-specified by the {\it flags} argument but its results for
+specified by the {\it flags} argument but its results for
\texttt{Sunday\_First} are not well-defined as the ISO definition quoted above
applies to the weeks starting on Monday only.
\texttt{Sunday\_First} are not well-defined as the ISO definition quoted above
applies to the weeks starting on Monday only.
\func{wxDateTime\&}{Set}{\param{unsigned long }{ddt}}
\func{wxDateTime\&}{Set}{\param{unsigned long }{ddt}}
-Sets the date from the date and time in
-\urlref{DOS}{http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms\_docs/data/hc2vlu5i.html}
+Sets the date from the date and time in
+\urlref{DOS}{http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms\_docs/data/hc2vlu5i.html}
\constfunc{unsigned long}{GetAsDOS}{\void}
\constfunc{unsigned long}{GetAsDOS}{\void}
-Returns the date and time in
-\urlref{DOS}{http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms\_docs/data/hc2vlu5i.html}
+Returns the date and time in
+\urlref{DOS}{http://developer.novell.com/ndk/doc/smscomp/index.html?page=/ndk/doc/smscomp/sms\_docs/data/hc2vlu5i.html}
format.
%%%%%%%%%%%%%%%%%%%%%%%%%%% comparison %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
format.
%%%%%%%%%%%%%%%%%%%%%%%%%%% comparison %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::ParseFormat}\label{wxdatetimeparseformat}
\membersection{wxDateTime::ParseFormat}\label{wxdatetimeparseformat}
-\func{const wxChar *}{ParseFormat}{\param{const wxChar *}{date}, \param{const wxChar *}{format = "\%c"}, \param{const wxDateTime\& }{dateDef = wxDefaultDateTime}}
+\func{const wxChar *}{ParseFormat}{\param{const wxChar *}{date}, \param{const wxChar *}{format = wxDefaultDateTimeFormat}, \param{const wxDateTime\& }{dateDef = wxDefaultDateTime}}
This function parses the string {\it date} according to the given
{\it format}. The system {\tt strptime(3)} function is used whenever available,
This function parses the string {\it date} according to the given
{\it format}. The system {\tt strptime(3)} function is used whenever available,
\func{const wxChar *}{ParseDate}{\param{const wxChar *}{date}}
This function is like \helpref{ParseDateTime}{wxdatetimeparsedatetime}, but it
\func{const wxChar *}{ParseDate}{\param{const wxChar *}{date}}
This function is like \helpref{ParseDateTime}{wxdatetimeparsedatetime}, but it
-only allows the date to be specified. It is thus less flexible then
+only allows the date to be specified. It is thus less flexible then
\helpref{ParseDateTime}{wxdatetimeparsedatetime}, but also has less chances to
misinterpret the user input.
\helpref{ParseDateTime}{wxdatetimeparsedatetime}, but also has less chances to
misinterpret the user input.
\membersection{wxDateTime::Format}\label{wxdatetimeformat}
\membersection{wxDateTime::Format}\label{wxdatetimeformat}
-\constfunc{wxString }{Format}{\param{const wxChar *}{format = "\%c"}, \param{const TimeZone\& }{tz = Local}}
+\constfunc{wxString }{Format}{\param{const wxChar *}{format = wxDefaultDateTimeFormat}, \param{const TimeZone\& }{tz = Local}}
This function does the same as the standard ANSI C {\tt strftime(3)} function.
Please see its description for the meaning of {\it format} parameter.
This function does the same as the standard ANSI C {\tt strftime(3)} function.
Please see its description for the meaning of {\it format} parameter.
\constfunc{wxDateTime}{GetWeekDayInSameWeek}{\param{WeekDay }{weekday}, \param{WeekFlags}{flags = {\tt Monday\_First}}}
\constfunc{wxDateTime}{GetWeekDayInSameWeek}{\param{WeekDay }{weekday}, \param{WeekFlags}{flags = {\tt Monday\_First}}}
-Returns the copy of this object to which
+Returns the copy of this object to which
\helpref{SetToWeekDayInSameWeek}{wxdatetimesettoweekdayinsameweek} was
applied.
\helpref{SetToWeekDayInSameWeek}{wxdatetimesettoweekdayinsameweek} was
applied.
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)
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
+contain days from different years. See
\helpref{GetWeekOfYear}{wxdatetimegetweekofyear} for the explanation of how the
year weeks are counted.
\helpref{GetWeekOfYear}{wxdatetimegetweekofyear} for the explanation of how the
year weeks are counted.
\membersection{wxTimeSpan::Format}\label{wxtimespanformat}
\membersection{wxTimeSpan::Format}\label{wxtimespanformat}
-\func{wxString}{Format}{\param{const wxChar * }{format = "\%H:\%M:\%S"}}
+\func{wxString}{Format}{\param{const wxChar * }{format = wxDefaultTimeSpanFormat}}
Returns the string containing the formatted representation of the time span.
The following format specifiers are allowed after \%:
Returns the string containing the formatted representation of the time span.
The following format specifiers are allowed after \%:
// wxInvalidDateTime)
class WXDLLIMPEXP_BASE wxDateTime;
// wxInvalidDateTime)
class WXDLLIMPEXP_BASE wxDateTime;
+extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultDateTimeFormat;
+extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxDefaultTimeSpanFormat;
extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
extern WXDLLIMPEXP_DATA_BASE(const wxDateTime) wxDefaultDateTime;
#define wxInvalidDateTime wxDefaultDateTime
// ----------------------------------------------------------------------------
#define wxInvalidDateTime wxDefaultDateTime
// ----------------------------------------------------------------------------
// default, they will not change if they had valid values or will
// default to Today() otherwise)
const wxChar *ParseFormat(const wxChar *date,
// default, they will not change if they had valid values or will
// default to Today() otherwise)
const wxChar *ParseFormat(const wxChar *date,
- const wxChar *format = _T("%c"),
+ const wxChar *format = wxDefaultDateTimeFormat,
const wxDateTime& dateDef = wxDefaultDateTime);
// parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents
const wxDateTime& dateDef = wxDefaultDateTime);
// parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents
// argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the
// resulting text representation
// argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the
// resulting text representation
- wxString Format(const wxChar *format = _T("%c"),
+ wxString Format(const wxChar *format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const;
// preferred date representation for the current locale
wxString FormatDate() const { return Format(_T("%x")); }
const TimeZone& tz = Local) const;
// preferred date representation for the current locale
wxString FormatDate() const { return Format(_T("%x")); }
// resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example.
// resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example.
- wxString Format(const wxChar *format = _T("%H:%M:%S")) const;
+ wxString Format(const wxChar *format = wxDefaultTimeSpanFormat) const;
// implementation
// ------------------------------------------------------------------------
// implementation
// ------------------------------------------------------------------------
class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
{
public:
class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
{
public:
- wxGridCellDateTimeRenderer(wxString outformat = _T("%c"),
- wxString informat = _T("%c"));
+ wxGridCellDateTimeRenderer(wxString outformat = wxDefaultDateTimeFormat,
+ wxString informat = wxDefaultDateTimeFormat);
// draw the string right aligned
virtual void Draw(wxGrid& grid,
// draw the string right aligned
virtual void Draw(wxGrid& grid,
// global data
// ----------------------------------------------------------------------------
// global data
// ----------------------------------------------------------------------------
+const wxChar * wxDefaultDateTimeFormat = wxT("%c");
+const wxChar * wxDefaultTimeSpanFormat = wxT("%H:%M:%S");
+
// in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to
// indicate an invalid wxDateTime object
const wxDateTime wxDefaultDateTime;
// in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to
// indicate an invalid wxDateTime object
const wxDateTime wxDefaultDateTime;
#include <wtime.h>
#endif
#include <wtime.h>
#endif
+#include "wx/datetime.h"
+
// the suffix we add to the button to show that the dialog can be expanded
#define EXPAND_SUFFIX _T(" >>")
// the suffix we add to the button to show that the dialog can be expanded
#define EXPAND_SUFFIX _T(" >>")
if ( !fmt )
{
// default format
if ( !fmt )
{
// default format
+ fmt = wxDefaultDateTimeFormat;
}
size_t count = m_messages.GetCount();
}
size_t count = m_messages.GetCount();
if ( !fmt )
{
// default format
if ( !fmt )
{
// default format
+ fmt = wxDefaultDateTimeFormat;
}
size_t count = m_messages.GetCount();
}
size_t count = m_messages.GetCount();