datetime.tex
来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 1,547 行 · 第 1/4 页
TEX
1,547 行
Some degree of support for the date units used in astronomy and/or history is
provided. You can construct a wxDateTime object from a
\helpref{JDN}{wxdatetimesetjdn} and you may also get its JDN,
\helpref{MJD}{wxdatetimegetmodifiedjuliandaynumber} or
\helpref{Rata Die number}{wxdatetimegetratadie} from it.
\helpref{wxDateTime(double jdn)}{wxdatetimewxdatetimejdn}\\
\helpref{Set(double jdn)}{wxdatetimesetjdn}\\
\helpref{GetJulianDayNumber}{wxdatetimegetjuliandaynumber}\\
\helpref{GetJDN}{wxdatetimegetjdn}\\
\helpref{GetModifiedJulianDayNumber}{wxdatetimegetmodifiedjuliandaynumber}\\
\helpref{GetMJD}{wxdatetimegetmjd}\\
\helpref{GetRataDie}{wxdatetimegetratadie}
\membersection{Time zone and DST support}\label{datetimedstzone}
Please see the \helpref{time zone overview}{tdatetimezones} for more
information about time zones. Normally, these functions should be rarely used.
\helpref{FromTimezone}{wxdatetimefromtimezone}\\
\helpref{ToTimezone}{wxdatetimetotimezone}\\
\helpref{MakeTimezone}{wxdatetimemaketimezone}\\
\helpref{MakeFromTimezone}{wxdatetimemakefromtimezone}\\
\helpref{ToUTC}{wxdatetimetoutc}\\
\helpref{MakeUTC}{wxdatetimemakeutc}\\
\helpref{GetBeginDST}{wxdatetimegetbegindst}\\
\helpref{GetEndDST}{wxdatetimegetenddst}\\
\helpref{IsDST}{wxdatetimeisdst}
\helponly{\insertatlevel{2}{
\wxheading{Members}
}}
%%%%%%%%%%%%%%%%%%%%%%%%%%% static functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::ConvertYearToBC}\label{wxdatetimeconvertyeartobc}
\func{static int}{ConvertYearToBC}{\param{int }{year}}
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:
\begin{verbatim}
wxDateTime dt(...);
int y = dt.GetYear();
printf("The year is %d%s", wxDateTime::ConvertYearToBC(y), y > 0 ? "AD" : "BC");
\end{verbatim}
\membersection{wxDateTime::GetAmPmStrings}\label{wxdatetimegetampmstrings}
\func{static void}{GetAmPmStrings}{\param{wxString *}{am}, \param{wxString *}{pm}}
Returns the translations of the strings {\tt AM} and {\tt PM} used for time
formatting for the current locale. Either of the pointers may be {\tt NULL} if
the corresponding value is not needed.
\membersection{wxDateTime::GetBeginDST}\label{wxdatetimegetbegindst}
\func{static wxDateTime}{GetBeginDST}{\param{int }{year = Inv\_Year}, \param{Country }{country = Country\_Default}}
Get the beginning of DST for the given country in the given year (current one
by default). This function suffers from limitations described in
\helpref{DST overview}{tdatedst}.
\wxheading{See also}
\helpref{GetEndDST}{wxdatetimegetenddst}
\membersection{wxDateTime::GetCountry}\label{wxdatetimegetcountry}
\func{static Country}{GetCountry}{\void}
Returns the current default country. The default country is used for DST
calculations, for example.
\wxheading{See also}
\helpref{SetCountry}{wxdatetimesetcountry}
\membersection{wxDateTime::GetCurrentYear}\label{wxdatetimegetcurrentyear}
\func{static int}{GetCurrentYear}{\param{Calendar }{cal = Gregorian}}
Get the current year in given calendar (only Gregorian is currently supported).
\membersection{wxDateTime::GetCurrentMonth}\label{wxdatetimegetcurrentmonth}
\func{static Month}{GetCurrentMonth}{\param{Calendar }{cal = Gregorian}}
Get the current month in given calendar (only Gregorian is currently supported).
\membersection{wxDateTime::GetCentury}\label{wxdatetimegetcentury}
\func{static int}{GetCentury}{\param{int }{year = Inv\_Year}}
Get the current century, i.e. first two digits of the year, in given calendar
(only Gregorian is currently supported).
\membersection{wxDateTime::GetEndDST}\label{wxdatetimegetenddst}
\func{static wxDateTime}{GetEndDST}{\param{int }{year = Inv\_Year}, \param{Country }{country = Country\_Default}}
Returns the end of DST for the given country in the given year (current one by
default).
\wxheading{See also}
\helpref{GetBeginDST}{wxdatetimegetbegindst}
\membersection{wxDateTime::GetMonthName}\label{wxdatetimegetmonthname}
\func{static wxString}{GetMonthName}{\param{Month }{month}, \param{NameFlags }{flags = Name\_Full}}
Gets the full (default) or abbreviated (specify {\tt Name\_Abbr} name of the
given month.
\wxheading{See also}
\helpref{GetWeekDayName}{wxdatetimegetweekdayname}
\membersection{wxDateTime::GetNumberOfDays}\label{wxdatetimegetnumberofdays}
\func{static wxDateTime\_t}{GetNumberOfDays}{\param{int }{year}, \param{Calendar }{cal = Gregorian}}
\func{static wxDateTime\_t}{GetNumberOfDays}{\param{Month }{month}, \param{int }{year = Inv\_Year}, \param{Calendar }{cal = Gregorian}}
Returns the number of days in the given year or in the given month of the
year.
The only supported value for {\it cal} parameter is currently {\tt Gregorian}.
\pythonnote{These two methods are named {\tt GetNumberOfDaysInYear}
and {\tt GetNumberOfDaysInMonth} in wxPython.}
\membersection{wxDateTime::GetTimeNow}\label{wxdatetimegettimenow}
\func{static time\_t}{GetTimeNow}{\void}
Returns the current time.
\membersection{wxDateTime::GetTmNow}\label{wxdatetimegettmnow}
\func{static struct tm *}{GetTmNow}{\param{struct tm *}{tm}}
Returns the current time broken down, uses the buffer whose adress is
passed to the function via {\it tm} to store the result.
\membersection{wxDateTime::GetTmNow}
\func{static struct tm *}{GetTmNow}{\void}
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
the flavour of function \helpref{wxDateTime::GetTmNow}{wxdatetimegettmnow}
taking a parameter.
\membersection{wxDateTime::GetWeekDayName}\label{wxdatetimegetweekdayname}
\func{static wxString}{GetWeekDayName}{\param{WeekDay }{weekday}, \param{NameFlags }{flags = Name\_Full}}
Gets the full (default) or abbreviated (specify {\tt Name\_Abbr} name of the
given week day.
\wxheading{See also}
\helpref{GetMonthName}{wxdatetimegetmonthname}
\membersection{wxDateTime::IsLeapYear}\label{wxdatetimeisleapyear}
\func{static bool}{IsLeapYear}{\param{int }{year = Inv\_Year}, \param{Calendar }{cal = Gregorian}}
Returns {\tt true} if the {\it year} is a leap one in the specified calendar.
This functions supports Gregorian and Julian calendars.
\membersection{wxDateTime::IsWestEuropeanCountry}\label{wxdatetimeiswesteuropeancountry}
\func{static bool}{IsWestEuropeanCountry}{\param{Country }{country = Country\_Default}}
This function returns {\tt 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.
\membersection{wxDateTime::IsDSTApplicable}\label{wxdatetimeisdstapplicable}
\func{static bool}{IsDSTApplicable}{\param{int }{year = Inv\_Year}, \param{Country }{country = Country\_Default}}
Returns {\tt true} if DST was used n the given year (the current one by
default) in the given country.
\membersection{wxDateTime::Now}\label{wxdatetimenow}
\func{static wxDateTime}{Now}{\void}
Returns the object corresponding to the current time.
Example:
\begin{verbatim}
wxDateTime now = wxDateTime::Now();
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:
\helpref{wxDateTime::UNow}{wxdatetimeunow} should be used for better precision
(but it is less efficient and might not be available on all platforms).
\wxheading{See also}
\helpref{Today}{wxdatetimetoday}
\membersection{wxDateTime::SetCountry}\label{wxdatetimesetcountry}
\func{static void}{SetCountry}{\param{Country }{country}}
Sets the country to use by default. This setting influences the DST
calculations, date formatting and other things.
The possible values for {\it country} parameter are enumerated in
\helpref{wxDateTime constants section}{wxdatetime}.
\wxheading{See also}
\helpref{GetCountry}{wxdatetimegetcountry}
\membersection{wxDateTime::Today}\label{wxdatetimetoday}
\func{static wxDateTime}{Today}{\void}
Returns the object corresponding to the midnight of the current day (i.e. the
same as \helpref{Now()}{wxdatetimenow}, but the time part is set to $0$).
\wxheading{See also}
\helpref{Now}{wxdatetimenow}
\membersection{wxDateTime::UNow}\label{wxdatetimeunow}
\func{static wxDateTime}{UNow}{\void}
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).
\wxheading{See also}
\helpref{Now}{wxdatetimenow}
%%%%%%%%%%%%%%%%%%%%%%%%%%% constructors &c %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimedef}
\func{}{wxDateTime}{\void}
Default constructor. Use one of {\tt Set()} functions to initialize the object
later.
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimetimet}
\func{wxDateTime\&}{wxDateTime}{\param{time\_t }{timet}}
Same as \helpref{Set}{wxdatetimewxdatetimetimet}.
\pythonnote{This constructor is named {\tt wxDateTimeFromTimeT} in wxPython.}
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimetm}
\func{wxDateTime\&}{wxDateTime}{\param{const struct tm\& }{tm}}
Same as \helpref{Set}{wxdatetimewxdatetimetm}
\pythonnote{Unsupported.}
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimejdn}
\func{wxDateTime\&}{wxDateTime}{\param{double }{jdn}}
Same as \helpref{Set}{wxdatetimewxdatetimejdn}
\pythonnote{This constructor is named {\tt wxDateTimeFromJDN} in wxPython.}
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimetime}
\func{wxDateTime\&}{wxDateTime}{\param{wxDateTime\_t }{hour}, \param{wxDateTime\_t }{minute = 0}, \param{wxDateTime\_t }{second = 0}, \param{wxDateTime\_t }{millisec = 0}}
Same as \helpref{Set}{wxdatetimewxdatetimetime}
\pythonnote{This constructor is named {\tt wxDateTimeFromHMS} in wxPython.}
\membersection{wxDateTime::wxDateTime}\label{wxdatetimewxdatetimedate}
\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}
\pythonnote{This constructor is named {\tt wxDateTimeFromDMY} in wxPython.}
\membersection{wxDateTime::SetToCurrent}\label{wxdatetimesettocurrent}
\func{wxDateTime\&}{SetToCurrent}{\void}
Sets the date and time of to the current values. Same as assigning the result
of \helpref{Now()}{wxdatetimenow} to this object.
\membersection{wxDateTime::Set}\label{wxdatetimesettimet}
\func{wxDateTime\&}{Set}{\param{time\_t }{timet}}
Constructs the object from {\it timet} value holding the number of seconds
since Jan 1, 1970.
\pythonnote{This method is named {\tt SetTimeT} in wxPython.}
\membersection{wxDateTime::Set}\label{wxdatetimesettm}
\func{wxDateTime\&}{Set}{\param{const struct tm\& }{tm}}
Sets the date and time from the broken down representation in the standard
{\tt tm} structure.
\pythonnote{Unsupported.}
\membersection{wxDateTime::Set}\label{wxdatetimesetjdn}
\func{wxDateTime\&}{Set}{\param{double }{jdn}}
Sets the date from the so-called {\it 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.
\pythonnote{This method is named {\tt SetJDN} in wxPython.}
\membersection{wxDateTime::Set}\label{wxdatetimesettime}
\func{wxDateTime\&}{Set}{\param{wxDateTime\_t }{hour}, \param{wxDateTime\_t }{minute = 0}, \param{wxDateTime\_t }{second = 0}, \param{wxDateTime\_t }{millisec = 0}}
Sets the date to be equal to \helpref{Today}{wxdatetimetoday} and the time
from supplied parameters.
\pythonnote{This method is named {\tt SetHMS} in wxPython.}
\membersection{wxDateTime::Set}\label{wxdatetimesetdate}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?