Skip to main content

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:27

Parse a Gregorian calendar date string into a GregorianCalendarDate.

The input is expected to be in the form DD/MM/YYYY, optionally suffixed with " CE" or " BCE" and/or an asterisk (*). For BCE dates, 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:

  1. Converting the Gregorian date to a julian day using moonbeams
  2. Determining the offset needed based on the julian day
  3. Storing the adjusted julian day in the GregorianCalendarDate

Parameters

gregorian

string

Gregorian date string to parse (e.g. "01/01/0001 CE", "31/12/0001 BCE", or "01/01/2000*").

Returns

GregorianCalendarDate

A GregorianCalendarDate instance representing the given Gregorian date.

Throws

If the date string is invalid or malformed.