import { DateMarker , arrayToUtcDate , dateToUtcArray } from './marker' ; export interface CalendarSystem { getMarkerYear ( d ) : number ; getMarkerMonth ( d ) : number ; getMarkerDay ( d ) : number ; arrayToMarker ( arr ) : DateMarker ; markerToArray ( d ) : number [ ] ; } let calendarSystemClassMap = { } ; export function registerCalendarSystem ( name , theClass ) { calendarSystemClassMap [ name ] = theClass ; } export function createCalendarSystem ( name ) { return new calendarSystemClassMap [ name ] ( ) ; } class GregorianCalendarSystem implements CalendarSystem { getMarkerYear ( d ) { return d . getUTCFullYear ( ) ; } getMarkerMonth ( d ) { return d . getUTCMonth ( ) ; } getMarkerDay ( d ) { return d . getUTCDate ( ) ; } arrayToMarker ( arr ) { return arrayToUtcDate ( arr ) ; } markerToArray ( marker ) { return dateToUtcArray ( marker ) ; } } registerCalendarSystem ( 'gregory' , GregorianCalendarSystem ) ;