Common default datetime formats.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31439 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-01-17 21:29:23 +00:00
parent 9b877d1846
commit 1aaf88d220
6 changed files with 42 additions and 34 deletions

View File

@@ -1147,7 +1147,7 @@ free ways, you should use \helpref{ParseDateTime}{wxdatetimeparsedatetime} or
\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 This function parses the string {\it date} according to the given
{\it format}. The system {\tt strptime(3)} function is used whenever available, {\it format}. The system {\tt strptime(3)} function is used whenever available,
@@ -1211,7 +1211,7 @@ the character which stopped the scan.
\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. 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. Please see its description for the meaning of {\it format} parameter.

View File

@@ -115,7 +115,7 @@ Returns the timespan for one day.
\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. Returns the string containing the formatted representation of the time span.
The following format specifiers are allowed after \%: The following format specifiers are allowed after \%:

View File

@@ -110,7 +110,10 @@ class WXDLLIMPEXP_BASE wxDateSpan;
// wxInvalidDateTime) // wxInvalidDateTime)
class WXDLLIMPEXP_BASE wxDateTime; 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
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -935,7 +938,7 @@ public:
// default, they will not change if they had valid values or will // default, they will not change if they had valid values or will
// default to Today() otherwise) // default to Today() otherwise)
const wxChar *ParseFormat(const wxChar *date, const wxChar *ParseFormat(const wxChar *date,
const wxChar *format = _T("%c"), const wxChar *format = wxDefaultDateTimeFormat,
const wxDateTime& dateDef = wxDefaultDateTime); const wxDateTime& dateDef = wxDefaultDateTime);
// parse a string containing the date/time in "free" format, this // parse a string containing the date/time in "free" format, this
// function will try to make an educated guess at the string contents // function will try to make an educated guess at the string contents
@@ -950,7 +953,7 @@ public:
// argument corresponds to the preferred date and time representation // argument corresponds to the preferred date and time representation
// for the current locale) and returns the string containing the // for the current locale) and returns the string containing the
// resulting text representation // resulting text representation
wxString Format(const wxChar *format = _T("%c"), wxString Format(const wxChar *format = wxDefaultDateTimeFormat,
const TimeZone& tz = Local) const; const TimeZone& tz = Local) const;
// preferred date representation for the current locale // preferred date representation for the current locale
wxString FormatDate() const { return Format(_T("%x")); } wxString FormatDate() const { return Format(_T("%x")); }
@@ -1138,7 +1141,7 @@ public:
// resulting text representation. Notice that only some of format // resulting text representation. Notice that only some of format
// specifiers valid for wxDateTime are valid for wxTimeSpan: hours, // specifiers valid for wxDateTime are valid for wxTimeSpan: hours,
// minutes and seconds make sense, but not "PM/AM" string for example. // 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
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@@ -32,8 +32,8 @@
class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer class WXDLLIMPEXP_ADV wxGridCellDateTimeRenderer : public wxGridCellStringRenderer
{ {
public: public:
wxGridCellDateTimeRenderer(wxString outformat = _T("%c"), wxGridCellDateTimeRenderer(wxString outformat = wxDefaultDateTimeFormat,
wxString informat = _T("%c")); wxString informat = wxDefaultDateTimeFormat);
// draw the string right aligned // draw the string right aligned
virtual void Draw(wxGrid& grid, virtual void Draw(wxGrid& grid,

View File

@@ -233,6 +233,9 @@ static const wxDateTime::wxDateTime_t gs_cumulatedDays[2][MONTHS_IN_YEAR] =
// 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 // in the fine tradition of ANSI C we use our equivalent of (time_t)-1 to
// indicate an invalid wxDateTime object // indicate an invalid wxDateTime object
const wxDateTime wxDefaultDateTime; const wxDateTime wxDefaultDateTime;

View File

@@ -73,6 +73,8 @@
#include <wtime.h> #include <wtime.h>
#endif #endif
#include "wx/datetime.h"
// the suffix we add to the button to show that the dialog can be expanded // the suffix we add to the button to show that the dialog can be expanded
#define EXPAND_SUFFIX _T(" >>") #define EXPAND_SUFFIX _T(" >>")
@@ -866,7 +868,7 @@ void wxLogDialog::CreateDetailsControls()
if ( !fmt ) if ( !fmt )
{ {
// default format // default format
fmt = _T("%c"); fmt = wxDefaultDateTimeFormat;
} }
size_t count = m_messages.GetCount(); size_t count = m_messages.GetCount();
@@ -952,7 +954,7 @@ void wxLogDialog::OnSave(wxCommandEvent& WXUNUSED(event))
if ( !fmt ) if ( !fmt )
{ {
// default format // default format
fmt = _T("%c"); fmt = wxDefaultDateTimeFormat;
} }
size_t count = m_messages.GetCount(); size_t count = m_messages.GetCount();