import { Day } from './Day' ; import { Functions as fn } from './Functions' ; import { default as en } from './locales/en' ; import { Ref } from './Ref' ; /**
 * A locale object for generating a description for a rule. This handles all
 * types of frequencies (every with optional offset, one, or many).
 */ export interface LocaleRule { every ( every ) : string ; offset ( offset ) : string ; oneOf ( values ) : string ; } /**
 * Options that can be passed to date calculation functions that are used
 * in week calculations.
 */ export interface LocaleOptions { /**
     * The first day of the week in the locale.
     */ weekStartsOn : 0 | 1 | 2 | 3 | 4 | 5 | 6 ; /**
     * The date which determines which day of January decides the first week of
     * the year. If the first week of the year contains this date it will be the
     * 1st week of the year based on ISO standards. If the first week of the year
     * does not contain this date the weekOfYear will be 0.
     */ firstWeekContainsDate : 1 | 2 | 3 | 4 | 5 | 6 | 7 ; } /**
 * A definition of constants and functions which provide everything that's
 * needed for localization/internationalization support.
 */ export interface Locale extends LocaleOptions { suffix ( value ) : string ; am : string ; pm : string ; formatLT : string ; formatLTS : string ; formatL : string ; formatl : string ; formatLL : string ; formatll : string ; formatLLL : string ; formatlll : string ; formatLLLL : string ; formatllll : string ; identifierTime ( short ) : string ; identifierDay ( short ) : string ; identifierWeek ( short ) : string ; identifierMonth ( short ) : string ; identifierQuarter ( short ) : string ; identifierYear ( short ) : string ; patternNone ( day ) : string ; patternDaily ( day ) : string ; patternWeekly ( day ) : string ; patternMonthlyWeek ( day ) : string ; patternAnnually ( day ) : string ; patternAnnuallyMonthWeek ( day ) : string ; patternWeekday ( day ) : string ; patternMonthly ( day ) : string ; patternLastDay ( day ) : string ; patternLastDayOfMonth ( day ) : string ; patternLastWeekday ( day ) : string ; patternCustom ( day ) : string ; scheduleStartingOn ( start ) : string ; scheduleEndingOn ( end ) : string ; scheduleEndsOn ( end ) : string ; scheduleThing ( thing , start ) : string ; scheduleAtTimes : string ; scheduleDuration ( duration , unit ? ) : string ; scheduleExcludes : string ; scheduleIncludes : string ; scheduleCancels : string ; ruleDayOfWeek : LocaleRule ; ruleLastDayOfMonth : LocaleRule ; ruleDayOfMonth : LocaleRule ; ruleDayOfYear : LocaleRule ; ruleYear : LocaleRule ; ruleMonth : LocaleRule ; ruleDay : LocaleRule ; ruleWeek : LocaleRule ; ruleWeekOfYear : LocaleRule ; ruleWeekspanOfYear : LocaleRule ; ruleFullWeekOfYear : LocaleRule ; ruleLastWeekspanOfYear : LocaleRule ; ruleLastFullWeekOfYear : LocaleRule ; ruleWeekOfMonth : LocaleRule ; ruleFullWeekOfMonth : LocaleRule ; ruleWeekspanOfMonth : LocaleRule ; ruleLastFullWeekOfMonth : LocaleRule ; ruleLastWeekspanOfMonth : LocaleRule ; summaryDay ( short , dayOfWeek , year ) : string ; summaryWeek ( short , dayOfWeek , year ) : string ; summaryMonth ( short , dayOfWeek , year ) : string ; summaryYear ( short , dayOfWeek , year ) : string ; list ( items ) : string ; months : [ [ string , string , string , string , string , string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string , string , string , string , string , string ] ] ; weekdays : [ [ string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string ] , [ string , string , string , string , string , string , string ] ] ; } /**
 * A class for holding all supported locales. You can add your own,
 * add aliases, or set the current locale.
 */ export class Locales { /**
     * The map of locales available.
     */ public static map : { [ key ] : Locale ; } = { en } ; /**
     * The reference to the current locale.
     */ public static ref : Ref < Locale > = new Ref < Locale > ( en , true ) ; param key param locale public static add ( key , locale ) { const keys = fn . isArray ( key ) ? key : [ key ] ; for ( const k of keys ) { this . map [ this . normal ( k ) ] = locale ; } } param key param aliases public static alias ( key , aliases ) { const aliased = this . map [ this . normal ( key ) ] ; for ( const k of aliases ) { this . map [ this . normal ( k ) ] = aliased ; } } param key returns public static set ( key ) { const n = this . normal ( key ) ; const has = n in this . map ; if ( has ) { this . ref = this . ref . getReplace ( this . map [ n ] ) ; } return has ; } param x public static normal ( x ) { return x . toLowerCase ( ) ; } param key public static get ( key ) { const n = this . normal ( key ) ; return n in this . map ? this . map [ n ] : this . current ; } /**
     * The current locale.
     */ public static get current ( ) : Locale { return this . ref . value ; } }