Class

HanDate

HanDate(paramsopt)

Construct a new Han date object. The constructor parameters can contain any of the following properties:

  • unixtime - sets the time of this instance according to the given unix time. Unix time is the number of milliseconds since midnight on Jan 1, 1970, Gregorian
  • julianday - sets the time of this instance according to the given Julian Day instance or the Julian Day given as a float
  • cycle - any integer giving the number of 60-year cycle in which the date is located. If the cycle is not given but the year is, it is assumed that the year parameter is a fictitious linear count of years since the beginning of the epoch, much like other calendars. This linear count is never used. If both the cycle and year are given, the year is wrapped to the range 0 to 60 and treated as if it were a year in the regular 60-year cycle.
  • year - any integer, including 0
  • month - 1 to 12, where 1 means Farvardin, 2 means Ordibehesht, etc.
  • day - 1 to 31
  • hour - 0 to 23. A formatter is used to display 12 hour clocks, but this representation is always done with an unambiguous 24 hour representation
  • minute - 0 to 59
  • second - 0 to 59
  • millisecond - 0 to 999
  • timezone - the TimeZone instance or time zone name as a string of this han date. The date/time is kept in the local time. The time zone is used later if this date is formatted according to a different time zone and the difference has to be calculated, or when the date format has a time zone component in it.
  • locale - locale for this han date. If the time zone is not given, it can be inferred from this locale. For locales that span multiple time zones, the one with the largest population is chosen as the one that represents the locale.
  • date - use the given intrinsic Javascript date to initialize this one.

If the constructor is called with another Han date instance instead of a parameter block, the other instance acts as a parameter block and its settings are copied into the current instance.

If the constructor is called with no arguments at all or if none of the properties listed above from unixtime through millisecond are present, then the date components are filled in with the current date at the time of instantiation. Note that if you do not give the time zone when defaulting to the current time and the time zone for all of ilib was not set with ilib.setTimeZone(), then the time zone will default to UTC ("Universal Time, Coordinated" or "Greenwich Mean Time").

If any of the properties from year through millisecond are not specified in the params, it is assumed that they have the smallest possible value in the range for the property (zero or one).

Constructor

# new HanDate(paramsopt)

Parameters:
Name Type Attributes Description
params Object <optional>

parameters that govern the settings and behaviour of this Han date

View Source HanDate.js, line 106

Extends

  • Date

Members

number

# cycle

Cycle number in the Han calendar.

View Source HanDate.js, line 157

number

# cycleYear

Year in the cycle of the Han calendar

View Source HanDate.js, line 218

number

# day

The day of the month. This ranges from 1 to 30.

View Source HanDate.js, line 185

number

# dayOfYear

The day of the year. Ranges from 1 to 384.

View Source HanDate.js, line 224

number

# hour

The hour of the day. This can be a number from 0 to 23, as times are stored unambiguously in the 24-hour clock.

View Source HanDate.js, line 192

number

# millisecond

The millisecond of the second. Ranges from 0 to 999.

View Source HanDate.js, line 210

number

# minute

The minute of the hours. Ranges from 0 to 59.

View Source HanDate.js, line 198

number

# month

The month number, ranging from 1 to 13

View Source HanDate.js, line 179

number

# second

The second of the minute. Ranges from 0 to 59.

View Source HanDate.js, line 204

number

# year

Year in the Han calendar.

View Source HanDate.js, line 165

Methods

# getCalendar() → {string}

Return the name of the calendar that governs this date.

View Source HanDate.js, line 540

a string giving the name of the calendar

string

# getCycleYears() → {number}

Return the year within the Chinese cycle of this date. Cycles are 60 years long, and the value returned from this method is the number of the year within this cycle. The year returned from getYear() is the total elapsed years since the beginning of the Chinese epoch and does not include the cycles.

View Source HanDate.js, line 460

the year within the current Chinese cycle

number

# getCycles() → {number}

Return the Chinese cycle number of this date. Cycles are 60 years long, and the value returned from getCycleYear() is the number of the year within this cycle. The year returned from getYear() is the total elapsed years since the beginning of the Chinese epoch and does not include the cycles.

View Source HanDate.js, line 473

the current Chinese cycle

number

# getDayOfWeek() → {number}

Return the day of the week of this date. The day of the week is encoded as number from 0 to 6, with 0=Sunday, 1=Monday, etc., until 6=Saturday.

View Source HanDate.js, line 505

the day of the week

number

# getDayOfYear() → {number}

Return the ordinal day of the year. Days are counted from 1 and proceed linearly up to 365, regardless of months or weeks, etc. That is, Farvardin 1st is day 1, and December 31st is 365 in regular years, or 366 in leap years.

View Source HanDate.js, line 516

the ordinal day of the year

number

# getEra() → {number}

Return the era for this date as a number. The value for the era for Han calendars is -1 for "before the han era" (BP) and 1 for "the han era" (anno persico or AP). BP dates are any date before Farvardin 1, 1 AP. In the proleptic Han calendar, there is a year 0, so any years that are negative or zero are BP.

View Source HanDate.js, line 531

1 if this date is in the common era, -1 if it is before the common era

number

# isLeapMonth() → {boolean}

Return whether the month of this date is a leap month in the Chinese Han calendar.

View Source HanDate.js, line 495

true if the month of this date is a leap month in the Chinese Han calendar.

boolean

# isLeapYear() → {boolean}

Return whether the year of this date is a leap year in the Chinese Han calendar.

View Source HanDate.js, line 484

true if the year of this date is a leap year in the Chinese Han calendar.

boolean

# protected newRd(paramsopt) → {RataDie}

Return a new RD for this date type using the given params.

Parameters:
Name Type Attributes Description
params Object <optional>

the parameters used to create this rata die instance

View Source HanDate.js, line 324

the new RD instance for the given params

RataDie