Mid 2005: Initial release
Apr 2007: reshaped
John Chapman, Kris
- class Calendar [public, abstract] ¶
-
Represents time in week, month and year divisions.
- enum [package] ¶
-
Indicates the current era of the calendar.
- Date toDate(const(Time) time) [const] ¶
-
Get the components of a Time structure using the rules of the
calendar. This is useful if you want more than one of the given
components. Note that this doesn't handle the time of day, as that
is calculated directly from the Time struct.
The default implemenation is to call all the other accessors
directly, a derived class may override if it has a more efficient
method.
- void split(const(Time) time, ref uint year, ref uint month, ref uint day, ref uint doy, ref uint dow, ref uint era) [const] ¶
-
Get the components of a Time structure using the rules of the
calendar. This is useful if you want more than one of the given
components. Note that this doesn't handle the time of day, as that
is calculated directly from the Time struct.
The default implemenation is to call all the other accessors
directly, a derived class may override if it has a more efficient
method.
- Time toTime(uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond = 0) [const] ¶
-
Returns a Time value set to the specified date and time in the current era.
year | An integer representing the _year. |
month | An integer representing the _month. |
day | An integer representing the _day. |
hour | An integer representing the _hour. |
minute | An integer representing the _minute. |
second | An integer representing the _second. |
millisecond | An integer representing the _millisecond. |
The Time set to the specified date and time.
- Time toTime(const(Date) d) [const] ¶
-
Returns a Time value for the given Date, in the current era
date | a representation of the Date |
The Time set to the specified date.
- Time toTime(const(DateTime) dt) [const] ¶
-
Returns a Time value for the given DateTime, in the current era
dt | a representation of the date and time |
The Time set to the specified date and time.
- Time toTime(const(Date) d, const(TimeOfDay) t) [const] ¶
-
Returns a Time value for the given Date and TimeOfDay, in the current era
d | a representation of the date |
t | a representation of the day time |
The Time set to the specified date and time.
- Time toTime(uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond, uint era) [const, abstract] ¶
-
When overridden, returns a Time value set to the specified date and time in the specified _era.
year | An integer representing the _year. |
month | An integer representing the _month. |
day | An integer representing the _day. |
hour | An integer representing the _hour. |
minute | An integer representing the _minute. |
second | An integer representing the _second. |
millisecond | An integer representing the _millisecond. |
era | An integer representing the _era. |
A Time set to the specified date and time.
- DayOfWeek getDayOfWeek(const(Time) time) [const, abstract] ¶
-
When overridden, returns the day of the week in the specified Time.
A DayOfWeek value representing the day of the week of time.
- uint getDayOfMonth(const(Time) time) [const, abstract] ¶
-
When overridden, returns the day of the month in the specified Time.
An integer representing the day of the month of time.
- uint getDayOfYear(const(Time) time) [const, abstract] ¶
-
When overridden, returns the day of the year in the specified Time.
An integer representing the day of the year of time.
- uint getMonth(const(Time) time) [const, abstract] ¶
-
When overridden, returns the month in the specified Time.
An integer representing the month in time.
- uint getYear(const(Time) time) [const, abstract] ¶
-
When overridden, returns the year in the specified Time.
An integer representing the year in time.
- uint getEra(const(Time) time) [const, abstract] ¶
-
When overridden, returns the era in the specified Time.
An integer representing the ear in time.
- uint getDaysInMonth(uint year, uint month) [const] ¶
-
Returns the number of days in the specified _year and _month of the current era.
year | An integer representing the _year. |
month | An integer representing the _month. |
The number of days in the specified _year and _month of the current era.
- uint getDaysInMonth(uint year, uint month, uint era) [const, abstract] ¶
-
When overridden, returns the number of days in the specified _year and _month of the specified _era.
year | An integer representing the _year. |
month | An integer representing the _month. |
era | An integer representing the _era. |
The number of days in the specified _year and _month of the specified _era.
- uint getDaysInYear(uint year) [const] ¶
-
Returns the number of days in the specified _year of the current era.
year | An integer representing the _year. |
The number of days in the specified _year in the current era.
- uint getDaysInYear(uint year, uint era) [const, abstract] ¶
-
When overridden, returns the number of days in the specified _year of the specified _era.
year | An integer representing the _year. |
era | An integer representing the _era. |
The number of days in the specified _year in the specified _era.
- uint getMonthsInYear(uint year) [const] ¶
-
Returns the number of months in the specified _year of the current era.
year | An integer representing the _year. |
The number of months in the specified _year in the current era.
- uint getMonthsInYear(uint year, uint era) [const, abstract] ¶
-
When overridden, returns the number of months in the specified _year of the specified _era.
year | An integer representing the _year. |
era | An integer representing the _era. |
The number of months in the specified _year in the specified _era.
- uint getWeekOfYear(const(Time) time, WeekRule rule, DayOfWeek firstDayOfWeek) [const] ¶
-
Returns the week of the year that includes the specified Time.
time | A Time value. |
rule | A WeekRule value defining a calendar week. |
firstDayOfWeek | A DayOfWeek value representing the first day of the week. |
An integer representing the week of the year that includes the date in time.
- bool isLeapYear(uint year) [const] ¶
-
Indicates whether the specified _year in the current era is a leap _year.
year | An integer representing the _year. |
true is the specified _year is a leap _year; otherwise, false.
- bool isLeapYear(uint year, uint era) [const, abstract] ¶
-
When overridden, indicates whether the specified _year in the specified _era is a leap _year.
year | An integer representing the _year. |
era | An integer representing the _era. |
true is the specified _year is a leap _year; otherwise, false.
- uint[] eras() [@property, const, abstract] ¶
-
Property. When overridden, retrieves the list of eras in the current calendar.
An integer array representing the eras in the current calendar.
- uint id() [@property, const] ¶
-
Property. Retrieves the identifier associated with the current calendar.
An integer representing the identifier of the current calendar.
- Time addMonths(const(Time) t, int nMonths, bool truncateDay = false) [const] ¶
-
Returns a new Time with the specified number of months added. If
the months are negative, the months are subtracted.
If the target month does not support the day component of the input
time, then an error will be thrown, unless truncateDay is set to
true. If truncateDay is set to true, then the day is reduced to
the maximum day of that month.
For example, adding one month to 1/31/2000 with truncateDay set to
true results in 2/28/2000.
The default implementation uses information provided by the
calendar to calculate the correct time to add. Derived classes may
override if there is a more optimized method.
Note that the generic method does not take into account crossing
era boundaries. Derived classes may support this.
t | A time to add the months to |
nMonths | The number of months to add. This can be
negative. |
truncateDay | Round the day down to the maximum day of the
target month if necessary. |
A Time that represents the provided time with the number
of months added.
- Time addYears(const(Time) t, int nYears) [const] ¶
-
Add the specified number of years to the given Time.
The generic algorithm uses information provided by the abstract
methods. Derived classes may re-implement this in order to
optimize the algorithm
Note that the generic algorithm does not take into account crossing
era boundaries. Derived classes may support this.
t | A time to add the years to |
nYears | The number of years to add. This can be negative. |
A Time that represents the provided time with the number
of years added.