📄 zdate.man
字号:
Example zDate date(zDate::oct, 11, 1996);
assert(date.AddWeeks(-1) == zDate(zDate::oct,4,1996));
ZDATE::ADDYEARS
--------------------------------------------------------------------------
Synopsis Adds or subtracts a number of years from a date.
Syntax zDate AddYears(int nYears) const;
Remarks This member function will add or subtract (if 'nYears' is
negative) a number of years to the current date object and
will return a new zDate with the resulting value. The calling
object is not modified by this function. Note that when
manipulating years, a date could become invalidated (such as
adding 1 to a leap year will cause February 29 to be an
invalid date). This routine takes that into account and will
adjust itself accordingly (in the example above, the new date
will be March 1). Care must be taken that years do not fall
below 1 A.D.
Return A zDate object with the new date.
See also zDate::AddWeeks(); zDate::AddMonths(); zDate::operator+();
Example zDate date(zDate::feb, 29, 1996);
assert(date.AddYears(-2) == zDate(zDate::mar,1,1994));
ZDATE::AGE
--------------------------------------------------------------------------
Synopsis Returns the age of someone with a specific birthrate
(for current date object).
Syntax int Age(const zDate &BirthDay) const;
Remarks This routine calculates the age of a person with a birthday
date of 'BirthDay'. This function does not modify the calling
object. Care must be taken that the calling object is greater
than BirthDay (i.e. that the person has already been born).
Return The age (in years) of the person.
See also zDate::operator-()
Example zDate brani(zDate::jul, 16, 1973);
cout << "I am " << Today().Age(brani) << " years old";
ZDATE::BEGINDST
--------------------------------------------------------------------------
Synopsis Calculates the beginning date of the Daylight Savings Time.
Syntax zDate BeginDST() const;
static zDate BeginDST(int aYear);
Remarks There are two version of this function. The first one returns
the date of the beginning of DST for the year of the current
date object. The second one is more generic as it returns the
start of DST for any year. These routine do not modify
anything, they simply return a zDate object with the date
when the DST comes into effect. By default, the routines will
use the USA standard for DST calculations. In the US, DST
begins at 2:00am on the first Sunday of April and ends at
2:00am on the last Sunday of October. You can modify these
rules by using the SetBeginDST() and SetEndDST() member
functions.
Return The date when DST will come into effect.
See also zDate::EndDST(); zDate::IsDST(); zDate::SetBeginDST()
Example assert(zDate::BeginDST(1996)==zDate(zDate::apr,7,1996))
ZDATE::DAY
--------------------------------------------------------------------------
Synopsis Returns the day of month of the current date object.
Syntax int Day() const;
Remarks This routine return the current day of the month. Days start
from 1 and can go up to 31, depending on the current day.
Note that there are no days between October 4 and October 15,
1582 (this is when Pope Gregor XIII canceled them).
Return The day of the month.
See also zDate::Month(); zDate::Year(); zDate::DayOfWeek();
Example cout << "Today is the " << zDate::Today().Day()
<< "th day of the month";
ZDATE::DAYNUMBER
--------------------------------------------------------------------------
Synopsis Returns the day number (from January 1, 1) for the object.
Syntax ulong DayNumber() const;
Remarks This returns the day number of the date object. Day numbering
begins with January 1, 0001 A.D. being day 1 and so on. As
such, these day numbers are not Julian dates (which begin
several thousand years B.C.). Leap years are taken into
account as well as the Gregorian reform (with the standard
date of October 4, 1582)
Return The day number (unsigned long integer).
See also zDate::zDate(ulong nDayNumber);
Example cout << "Today is the " << zDate::Today().DayNumber()
<< "th day of the year.";
ZDATE::DAYOFWEEK
--------------------------------------------------------------------------
Synopsis Returns the day of the week for the date object.
Syntax week_day DayOfWeek() const;
Remarks This returns the day of the week for the current date object.
You must use the week_day enumeration to interpret the return
value of this function. When trying to access the week_day
constants, be sure to use the scope resolution operator.
Return The day of the week.
See also zDate::week_day;
Example assert(zDate::sat == zDate(zDate::oct,5,1996).DayOfWeek());
ZDATE::DAYOFYEAR
--------------------------------------------------------------------------
Synopsis Returns the day of the year from January 1.
Syntax int DayOfYear() const;
Remarks This member function returns the day of the year for the
current object. The day numbering starts from January 1 for
the same year being the first day. The current day number
will depend on whether the year is leap or not too. The range
of possible values is 1..366 (or 365 for non-leap years),
with the upper limit being December 31.
Return The day number.
See also zDate::DayOfWeek(); zDate::DayNumber();
Example assert(366 == zDate(zDate::dec,31,2000).DayOfYear());
ZDATE::DAYSINMONTH
--------------------------------------------------------------------------
Synopsis Returns the number of days for a specific month in a year.
Syntax int DaysInMonth() const;
static int DaysInMonth(month aMonth, int aYear);
Remarks These two versions of the function will return the number of
days for a specific month. The first version will return the
number of days in the month of the date object that called it;
while the second version can be used without an actual zDate
object and returns the number of days for a month of a year
you specify. Note that October 1582 had only 21 days as a
result of the reform of Pope Gregor XIII.
Return The number of days in a month.
See also zDate::DaysInYear(); zDate::IsLeapYear();
Example assert( 28 == zDate::DaysInMonth(zDate::feb, 1995) );
ZDATE::DAYSINYEAR
--------------------------------------------------------------------------
Synopsis Returns the number of days in a specific year.
Syntax int DaysInYear() const;
static int DaysInYear(int aYear);
Remarks The first version of this routine returns the number of days
in the year of the current date object. The second version
can be used without instantiating an actual object and returns
the number of days in any year. There are two possible values
365 and 366 depending on whether the year is leap or not
(except for 1582 which lost 10 days). These functions do not
modify any objects.
Return The number of days in a year.
See also zDate::DaysInMonth(); zDate::IsLeapYear();
Example assert( 366 == zDate::DaysInYear(1996) );
ZDATE::EASTER
--------------------------------------------------------------------------
Synopsis Return the date of Easter for any given year.
Syntax zDate Easter() const;
static zDate Easter(int year);
Remarks This routine returns the date for Easter for any given year
(the second version) or for the year of the calling zDate
object. It uses some obscure algorithm to calculate the
ecclesiastical Easter (which is the same for all countries
regardless of where they are) and is different from the
astronomical date (which does not mean much anyway). Easter is
sometimes said to be the first Sunday that occurs after the
full moon that follows the vernal equinox (March 22). This
means the Easter can vary between March 22 and April 25. This
is an over-simplification as the Church does not actually use
astronomical observations of the Moon but rather, it has
constructed its own calendar of Easter days which it uses.
This function is a very presentable approximation. For more
information, read one of the Almanacs or visit the US Naval
Observatory. They have tons of nice information there,
including an even more obfuscated formula for calculating the
Easter date.
Return A zDate object with the Easter date.
See also zDate::MoonPhase(); zDate::DayOfWeek()
Example zDate Easter(zDate::apr, 7, 1996);
assert( Easter == zDate::Easter(1996) );
ZDATE::ENDDST
--------------------------------------------------------------------------
Synopsis Return the date when the Daylight Savings Time is ended.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -