tango.time.chrono.Calendar

License:

BSD style: see license.txt

Version:

Mid 2005: Initial release Apr 2007: reshaped

Author:

John Chapman, Kris
class Calendar [public, abstract]
Represents time in week, month and year divisions.

Remarks:

Calendar is the abstract base class for the following Calendar implementations: Gregorian, Hebrew, Hijri, Japanese, Korean, Taiwan and ThaiBuddhist.
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.

Parameters:

yearAn integer representing the _year.
monthAn integer representing the _month.
dayAn integer representing the _day.
hourAn integer representing the _hour.
minuteAn integer representing the _minute.
secondAn integer representing the _second.
millisecondAn integer representing the _millisecond.

Returns:

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

Parameters:

datea representation of the Date

Returns:

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

Parameters:

dta representation of the date and time

Returns:

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

Parameters:

da representation of the date
ta representation of the day time

Returns:

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.

Parameters:

yearAn integer representing the _year.
monthAn integer representing the _month.
dayAn integer representing the _day.
hourAn integer representing the _hour.
minuteAn integer representing the _minute.
secondAn integer representing the _second.
millisecondAn integer representing the _millisecond.
eraAn integer representing the _era.

Returns:

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.

Parameters:

timeA Time value.

Returns:

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.

Parameters:

timeA Time value.

Returns:

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.

Parameters:

timeA Time value.

Returns:

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.

Parameters:

timeA Time value.

Returns:

An integer representing the month in time.
uint getYear(const(Time) time) [const, abstract]
When overridden, returns the year in the specified Time.

Parameters:

timeA Time value.

Returns:

An integer representing the year in time.
uint getEra(const(Time) time) [const, abstract]
When overridden, returns the era in the specified Time.

Parameters:

timeA Time value.

Returns:

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.

Parameters:

yearAn integer representing the _year.
monthAn integer representing the _month.

Returns:

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.

Parameters:

yearAn integer representing the _year.
monthAn integer representing the _month.
eraAn integer representing the _era.

Returns:

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.

Parameters:

yearAn integer representing the _year.

Returns:

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.

Parameters:

yearAn integer representing the _year.
eraAn integer representing the _era.

Returns:

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.

Parameters:

yearAn integer representing the _year.

Returns:

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.

Parameters:

yearAn integer representing the _year.
eraAn integer representing the _era.

Returns:

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.

Parameters:

timeA Time value.
ruleA WeekRule value defining a calendar week.
firstDayOfWeekA DayOfWeek value representing the first day of the week.

Returns:

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.

Parameters:

yearAn integer representing the _year.

Returns:

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.

Parameters:

yearAn integer representing the _year.

Parameters:

eraAn integer representing the _era.

Returns:

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.

Returns:

An integer array representing the eras in the current calendar.
uint id() [@property, const]
Property. Retrieves the identifier associated with the current calendar.

Returns:

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.

Parameters:

tA time to add the months to

Parameters:

nMonthsThe number of months to add. This can be negative.

Parameters:

truncateDayRound the day down to the maximum day of the target month if necessary.

Returns:

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.

Parameters:

tA time to add the years to

Parameters:

nYearsThe number of years to add. This can be negative.

Returns:

A Time that represents the provided time with the number of years added.