GregorianFactory
Defined in: factory/gregorian.ts:7
Factory for creating GregorianCalendarDate instances from Gregorian date strings.
Constructors
Constructor
new GregorianFactory():
GregorianFactory
Returns
GregorianFactory
Methods
parse()
parse(
gregorian):GregorianCalendarDate
Defined in: factory/gregorian.ts:30
Parse a Gregorian calendar date string into a GregorianCalendarDate.
Supports two input formats:
DD/MM/YYYYformat, optionally suffixed with" CE"or" BCE"and/or an asterisk (*)- ISO 8601 format:
YYYY-MM-DD(astronomical year numbering for BCE: -0001 = 2 BCE)
For BCE dates in DD/MM/YYYY format, the year component is converted to a negative year
before being passed to the moonbeams calendarToJd function.
The method calculates the appropriate julian day by:
- Converting the Gregorian date to a julian day using moonbeams
- Determining the offset needed based on the julian day
- Storing the adjusted julian day in the GregorianCalendarDate
Parameters
gregorian
string
Gregorian date string to parse. Examples:
- DD/MM/YYYY format:
"01/01/0001 CE","31/12/0001 BCE", or"01/01/2000*" - ISO 8601 format:
"2024-01-01","-0332-03-05"(333 BCE)
Returns
A GregorianCalendarDate instance representing the given Gregorian date.
Throws
If the date string is invalid or malformed.