tango.time.chrono.Calendar

License:
BSD style:

Version:
Mid 2005: Initial release Apr 2007: reshaped

author:
John Chapman, Kris

abstract class Calendar;
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.

const const Date toDate(const(Time) time);
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.

const const void split(const(Time) time, ref uint year, ref uint month, ref uint day, ref uint doy, ref uint dow, ref uint era);
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.

const const Time toTime(uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond = 0);
Returns a Time value set to the specified date and time in the current era.

Params:
uint year An integer representing the year.
uint month An integer representing the month.
uint day An integer representing the day.
uint hour An integer representing the hour.
uint minute An integer representing the minute.
uint second An integer representing the second.
uint millisecond An integer representing the millisecond.

Returns:
The Time set to the specified date and time.

const const Time toTime(const(Date) d);
Returns a Time value for the given Date, in the current era

Params:
date a representation of the Date

Returns:
The Time set to the specified date.

const const Time toTime(const(DateTime) dt);
Returns a Time value for the given DateTime, in the current era

Params:
const(DateTime) dt a representation of the date and time

Returns:
The Time set to the specified date and time.

const const Time toTime(const(Date) d, const(TimeOfDay) t);
Returns a Time value for the given Date and TimeOfDay, in the current era

Params:
const(Date) d a representation of the date
const(TimeOfDay) t a representation of the day time

Returns:
The Time set to the specified date and time.

abstract const const Time toTime(uint year, uint month, uint day, uint hour, uint minute, uint second, uint millisecond, uint era);
When overridden, returns a Time value set to the specified date and time in the specified era.

Params:
uint year An integer representing the year.
uint month An integer representing the month.
uint day An integer representing the day.
uint hour An integer representing the hour.
uint minute An integer representing the minute.
uint second An integer representing the second.
uint millisecond An integer representing the millisecond.
uint era An integer representing the era.

Returns:
A Time set to the specified date and time.

abstract const const DayOfWeek getDayOfWeek(const(Time) time);
When overridden, returns the day of the week in the specified Time.

Params:
const(Time) time A Time value.

Returns:
A DayOfWeek value representing the day of the week of time.

abstract const const uint getDayOfMonth(const(Time) time);
When overridden, returns the day of the month in the specified Time.

Params:
const(Time) time A Time value.

Returns:
An integer representing the day of the month of time.

abstract const const uint getDayOfYear(const(Time) time);
When overridden, returns the day of the year in the specified Time.

Params:
const(Time) time A Time value.

Returns:
An integer representing the day of the year of time.

abstract const const uint getMonth(const(Time) time);
When overridden, returns the month in the specified Time.

Params:
const(Time) time A Time value.

Returns:
An integer representing the month in time.

abstract const const uint getYear(const(Time) time);
When overridden, returns the year in the specified Time.

Params:
const(Time) time A Time value.

Returns:
An integer representing the year in time.

abstract const const uint getEra(const(Time) time);
When overridden, returns the era in the specified Time.

Params:
const(Time) time A Time value.

Returns:
An integer representing the ear in time.

const const uint getDaysInMonth(uint year, uint month);
Returns the number of days in the specified year and month of the current era.

Params:
uint year An integer representing the year.
uint month An integer representing the month.

Returns:
The number of days in the specified year and month of the current era.

abstract const const uint getDaysInMonth(uint year, uint month, uint era);
When overridden, returns the number of days in the specified year and month of the specified era.

Params:
uint year An integer representing the year.
uint month An integer representing the month.
uint era An integer representing the era.

Returns:
The number of days in the specified year and month of the specified era.

const const uint getDaysInYear(uint year);
Returns the number of days in the specified year of the current era.

Params:
uint year An integer representing the year.

Returns:
The number of days in the specified year in the current era.

abstract const const uint getDaysInYear(uint year, uint era);
When overridden, returns the number of days in the specified year of the specified era.

Params:
uint year An integer representing the year.
uint era An integer representing the era.

Returns:
The number of days in the specified year in the specified era.

const const uint getMonthsInYear(uint year);
Returns the number of months in the specified year of the current era.

Params:
uint year An integer representing the year.

Returns:
The number of months in the specified year in the current era.

abstract const const uint getMonthsInYear(uint year, uint era);
When overridden, returns the number of months in the specified year of the specified era.

Params:
uint year An integer representing the year.
uint era An integer representing the era.

Returns:
The number of months in the specified year in the specified era.

const const uint getWeekOfYear(const(Time) time, WeekRule rule, DayOfWeek firstDayOfWeek);
Returns the week of the year that includes the specified Time.

Params:
const(Time) time A Time value.
WeekRule rule A WeekRule value defining a calendar week.
DayOfWeek firstDayOfWeek A DayOfWeek value representing the first day of the week.

Returns:
An integer representing the week of the year that includes the date in time.

const const bool isLeapYear(uint year);
Indicates whether the specified year in the current era is a leap year.

Params:
uint year An integer representing the year.

Returns:
true is the specified year is a leap year; otherwise, false.

abstract const const bool isLeapYear(uint year, uint era);
When overridden, indicates whether the specified year in the specified era is a leap year.

Params:
uint year An integer representing the year.

Params:
uint era An integer representing the era.

Returns:
true is the specified year is a leap year; otherwise, false.

abstract const const @property uint[] eras();
Property. When overridden, retrieves the list of eras in the current calendar.

Returns:
An integer array representing the eras in the current calendar.

const const @property uint id();
Property. Retrieves the identifier associated with the current calendar.

Returns:
An integer representing the identifier of the current calendar.

const const Time addMonths(const(Time) t, int nMonths, bool truncateDay = false);
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.

Params:
const(Time) t A time to add the months to

Params:
int nMonths The number of months to add. This can be negative.

Params:
bool truncateDay Round 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.

const const Time addYears(const(Time) t, int nYears);
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.

Params:
const(Time) t A time to add the years to

Params:
int nYears The number of years to add. This can be negative.

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


Page generated by Ddoc. Copyright (c) 2005 John Chapman. All rights reserved