datetime.tex
来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 1,547 行 · 第 1/4 页
TEX
1,547 行
\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,
but even if it is not, this function is still implemented, although support
for locale-dependent format specifiers such as {\tt "\%c"}, {\tt "\%x"} or {\tt "\%X"} may
not be perfect and GNU extensions such as {\tt "\%z"} and {\tt "\%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 {\tt strftime(3)} for the syntax
of the format string.
The {\it dateDef} parameter is used to fill in the fields which could not be
determined from the format string. For example, if the format is {\tt "\%d"} (the
ay of the month), the month and the year are taken from {\it dateDef}. If
it is not specified, \helpref{Today}{wxdatetimetoday} is used as the
default date.
Returns {\tt NULL} if the conversion failed, otherwise return the pointer to
the character which stopped the scan.
\membersection{wxDateTime::ParseDateTime}\label{wxdatetimeparsedatetime}
\func{const wxChar *}{ParseDateTime}{\param{const wxChar *}{datetime}}
Parses the string {\it 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 \helpref{ParseRfc822Date}{wxdatetimeparserfc822date}, it
will accept anything that may be accepted and will only reject strings which
can not be parsed in any way at all.
Returns {\tt NULL} if the conversion failed, otherwise return the pointer to
the character which stopped the scan.
\membersection{wxDateTime::ParseDate}\label{wxdatetimeparsedate}
\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
\helpref{ParseDateTime}{wxdatetimeparsedatetime}, but also has less chances to
misinterpret the user input.
Returns {\tt NULL} if the conversion failed, otherwise return the pointer to
the character which stopped the scan.
\membersection{wxDateTime::ParseTime}\label{wxdatetimeparsetime}
\func{const wxChar *}{ParseTime}{\param{const wxChar *}{time}}
This functions is like \helpref{ParseDateTime}{wxdatetimeparsedatetime}, but
only allows the time to be specified in the input string.
Returns {\tt NULL} if the conversion failed, otherwise return the pointer to
the character which stopped the scan.
\membersection{wxDateTime::Format}\label{wxdatetimeformat}
\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.
It also accepts a few wxWidgets-specific extensions: you can optionally specify
the width of the field to follow using {\tt printf(3)}-like syntax and the
format specification {\tt \%l} can be used to get the number of milliseconds.
\wxheading{See also}
\helpref{ParseFormat}{wxdatetimeparseformat}
\membersection{wxDateTime::FormatDate}\label{wxdatetimeformatdate}
\constfunc{wxString }{FormatDate}{\void}
Identical to calling \helpref{Format()}{wxdatetimeformat} with {\tt "\%x"}
argument (which means `preferred date representation for the current locale').
\membersection{wxDateTime::FormatTime}\label{wxdatetimeformattime}
\constfunc{wxString }{FormatTime}{\void}
Identical to calling \helpref{Format()}{wxdatetimeformat} with {\tt "\%X"}
argument (which means `preferred time representation for the current locale').
\membersection{wxDateTime::FormatISODate}\label{wxdatetimeformatisodate}
\constfunc{wxString }{FormatISODate}{\void}
This function returns the date representation in the ISO 8601 format
(YYYY-MM-DD).
\membersection{wxDateTime::FormatISOTime}\label{wxdatetimeformatisotime}
\constfunc{wxString }{FormatISOTime}{\void}
This function returns the time representation in the ISO 8601 format
(HH:MM:SS).
%%%%%%%%%%%%%%%%%%%%%%%%%%% calendar calculations %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::SetToWeekDayInSameWeek}\label{wxdatetimesettoweekdayinsameweek}
\func{wxDateTime\&}{SetToWeekDayInSameWeek}{\param{WeekDay }{weekday}, \param{WeekFlags}{flags = {\tt 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.
\membersection{wxDateTime::GetWeekDayInSameWeek}\label{wxdatetimegetweekdayinsameweek}
\constfunc{wxDateTime}{GetWeekDayInSameWeek}{\param{WeekDay }{weekday}, \param{WeekFlags}{flags = {\tt Monday\_First}}}
Returns the copy of this object to which
\helpref{SetToWeekDayInSameWeek}{wxdatetimesettoweekdayinsameweek} was
applied.
\membersection{wxDateTime::SetToNextWeekDay}\label{wxdatetimesettonextweekday}
\func{wxDateTime\&}{SetToNextWeekDay}{\param{WeekDay }{weekday}}
Sets the date so that it will be the first {\it weekday} following the current
date.
Returns the reference to the modified object itself.
\membersection{wxDateTime::GetNextWeekDay}\label{wxdatetimegetnextweekday}
\constfunc{wxDateTime}{GetNextWeekDay}{\param{WeekDay }{weekday}}
Returns the copy of this object to which
\helpref{SetToNextWeekDay}{wxdatetimesettonextweekday} was applied.
\membersection{wxDateTime::SetToPrevWeekDay}\label{wxdatetimesettoprevweekday}
\func{wxDateTime\&}{SetToPrevWeekDay}{\param{WeekDay }{weekday}}
Sets the date so that it will be the last {\it weekday} before the current
date.
Returns the reference to the modified object itself.
\membersection{wxDateTime::GetPrevWeekDay}\label{wxdatetimegetprevweekday}
\constfunc{wxDateTime}{GetPrevWeekDay}{\param{WeekDay }{weekday}}
Returns the copy of this object to which
\helpref{SetToPrevWeekDay}{wxdatetimesettoprevweekday} was applied.
\membersection{wxDateTime::SetToWeekDay}\label{wxdatetimesettoweekday}
\func{bool}{SetToWeekDay}{\param{WeekDay }{weekday}, \param{int }{n = 1}, \param{Month }{month = Inv\_Month}, \param{int }{year = Inv\_Year}}
Sets the date to the {\it n}-th {\it weekday} in the given month of the given
year (the current month and year are used by default). The parameter {\it n}
may be either positive (counting from the beginning of the month) or negative
(counting from the end of it).
For example, {\tt SetToWeekDay(2, wxDateTime::Wed)} will set the date to the
second Wednesday in the current month and
{\tt SetToWeekDay(-1, wxDateTime::Sun)} -- to the last Sunday in it.
Returns {\tt true} if the date was modified successfully, {\tt false}
otherwise meaning that the specified date doesn't exist.
\membersection{wxDateTime::GetWeekDay}\label{wxdatetimegetweekday2}
\constfunc{wxDateTime}{GetWeekDay}{\param{WeekDay }{weekday}, \param{int }{n = 1}, \param{Month }{month = Inv\_Month}, \param{int }{year = Inv\_Year}}
Returns the copy of this object to which
\helpref{SetToWeekDay}{wxdatetimesettoweekday} was applied.
\membersection{wxDateTime::SetToLastWeekDay}\label{wxdatetimesettolastweekday}
\func{bool}{SetToLastWeekDay}{\param{WeekDay }{weekday}, \param{Month }{month = Inv\_Month}, \param{int }{year = Inv\_Year}}
The effect of calling this function is the same as of calling
{\tt SetToWeekDay(-1, weekday, month, year)}. The date will be set to the last
{\it weekday} in the given month and year (the current ones by default).
Always returns {\tt true}.
\membersection{wxDateTime::GetLastWeekDay}\label{wxdatetimegetlastweekday}
\func{wxDateTime}{GetLastWeekDay}{\param{WeekDay }{weekday}, \param{Month }{month = Inv\_Month}, \param{int }{year = Inv\_Year}}
Returns the copy of this object to which
\helpref{SetToLastWeekDay}{wxdatetimesettolastweekday} was applied.
\membersection{wxDateTime::SetToWeekOfYear}\label{wxdatetimesettoweekofyear}
\func{static wxDateTime}{SetToWeekOfYear}{\param{int }{year}, \param{wxDateTime\_t }{numWeek}, \param{WeekDay }{weekday = Mon}}
Set the date to the given \arg{weekday} in the week number \arg{numWeek} of the
given \arg{year} . The number should be in range $1\ldots53$.
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
\helpref{GetWeekOfYear}{wxdatetimegetweekofyear} for the explanation of how the
year weeks are counted.
\membersection{wxDateTime::SetToLastMonthDay}\label{wxdatetimesettolastmonthday}
\func{wxDateTime\&}{SetToLastMonthDay}{\param{Month }{month = Inv\_Month}, \param{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.
\membersection{wxDateTime::GetLastMonthDay}\label{wxdatetimegetlastmonthday}
\constfunc{wxDateTime}{GetLastMonthDay}{\param{Month }{month = Inv\_Month}, \param{int }{year = Inv\_Year}}
Returns the copy of this object to which
\helpref{SetToLastMonthDay}{wxdatetimesettolastmonthday} was applied.
\membersection{wxDateTime::SetToYearDay}\label{wxdatetimesettoyearday}
\func{wxDateTime\&}{SetToYearDay}{\param{wxDateTime\_t }{yday}}
Sets the date to the day number {\it 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\ldots366$ for the leap years and $1\ldots365$ for
the other ones.
Returns the reference to the modified object itself.
\membersection{wxDateTime::GetYearDay}\label{wxdatetimegetyearday}
\constfunc{wxDateTime}{GetYearDay}{\param{wxDateTime\_t }{yday}}
Returns the copy of this object to which
\helpref{SetToYearDay}{wxdatetimesettoyearday} was applied.
%%%%%%%%%%%%%%%%%%%%%%%%%%% astronomical functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::GetJulianDayNumber}\label{wxdatetimegetjuliandaynumber}
\constfunc{double}{GetJulianDayNumber}{\void}
Returns the \helpref{JDN}{wxdatetimesetjdn} corresponding to this date. Beware
of rounding errors!
\wxheading{See also}
\helpref{GetModifiedJulianDayNumber}{wxdatetimegetmodifiedjuliandaynumber}
\membersection{wxDateTime::GetJDN}\label{wxdatetimegetjdn}
\constfunc{double}{GetJDN}{\void}
Synonym for \helpref{GetJulianDayNumber}{wxdatetimegetjuliandaynumber}.
\membersection{wxDateTime::GetModifiedJulianDayNumber}\label{wxdatetimegetmodifiedjuliandaynumber}
\constfunc{double}{GetModifiedJulianDayNumber}{\void}
Returns the {\it Modified Julian Day Number} (MJD) which is, by definition,
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 th
noons like JDN. The MJD $0$ is Nov 17, 1858.
\membersection{wxDateTime::GetMJD}\label{wxdatetimegetmjd}
\constfunc{double}{GetMJD}{\void}
Synonym for \helpref{GetModifiedJulianDayNumber}{wxdatetimegetmodifiedjuliandaynumber}.
\membersection{wxDateTime::GetRataDie}\label{wxdatetimegetratadie}
\constfunc{double}{GetRataDie}{\void}
Return the {\it 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%% timezone and DST %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::FromTimezone}\label{wxdatetimefromtimezone}
\constfunc{wxDateTime}{FromTimezone}{\param{const TimeZone\& }{tz}, \param{bool }{noDST = false}}
Transform the date from the given time zone to the local one. If {\it noDST} is
{\tt true}, no DST adjustments will be made.
Returns the date in the local time zone.
\membersection{wxDateTime::ToTimezone}\label{wxdatetimetotimezone}
\constfunc{wxDateTime}{ToTimezone}{\param{const TimeZone\& }{tz}, \param{bool }{noDST = false}}
Transform the date to the given time zone. If {\it noDST} is {\tt true}, no
DST adjustments will be made.
Returns the date in the new time zone.
\membersection{wxDateTime::MakeTimezone}\label{wxdatetimemaketimezone}
\func{wxDateTime\&}{MakeTimezone}{\param{const TimeZone\& }{tz}, \param{bool }{noDST = false}}
Modifies the object in place to represent the date in another time zone. If
{\it noDST} is {\tt true}, no DST adjustments will be made.
\membersection{wxDateTime::MakeFromTimezone}\label{wxdatetimemakefromtimezone}
\func{wxDateTime\&}{MakeFromTimezone}{\param{const TimeZone\& }{tz}, \param{bool }{noDST = false}}
Same as \helpref{FromTimezone}{wxdatetimefromtimezone} but modifies the object
in place.
\membersection{wxDateTime::ToUTC}\label{wxdatetimetoutc}
\constfunc{wxDateTime}{ToUTC}{\param{bool }{noDST = false}}
This is the same as calling \helpref{ToTimezone}{wxdatetimetotimezone} with
the argument {\tt GMT0}.
\membersection{wxDateTime::MakeUTC}\label{wxdatetimemakeutc}
\func{wxDateTime\&}{MakeUTC}{\param{bool }{noDST = false}}
This is the same as calling \helpref{MakeTimezone}{wxdatetimemaketimezone} with
the argument {\tt GMT0}.
\membersection{wxDateTime::IsDST}\label{wxdatetimeisdst}
\constfunc{int}{IsDST}{\param{Country }{country = Country\_Default}}
Returns {\tt true} if the DST is applied for this date in the given country.
\wxheading{See also}
\helpref{GetBeginDST}{wxdatetimegetbegindst} and
\helpref{GetEndDST}{wxdatetimegetenddst}
\section{\class{wxDateTimeHolidayAuthority}}\label{wxdatetimeholidayauthority}
TODO
\section{\class{wxDateTimeWorkDays}}\label{wxdatetimeworkdays}
TODO
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?