import { Format } from './Format' ; import { Functions as fn } from './Functions' ; import { Locales } from './Locale' ; import { Time } from './Time' ; /**
 * Formats time into a string. The following list describes the available
 * formatting patterns:
 *
 * ### Hour
 * - H: 0-23
 * - HH: 00-23
 * - h: 12,1-12,1-11
 * - hh: 12,01-12,01-11
 * - k: 1-24
 * - kk: 01-24
 * - a: am,pm
 * - A: AM,PM
 * ### Minute
 * - m: 0-59
 * - mm: 00-59
 * ### Second
 * - s: 0-59
 * - ss: 00-59
 * ### Millisecond
 * - S: 0-9
 * - SS: 00-99
 * - SSS: 000-999
 */ export const TimeFormat = new Format < Time > ( { A : ( t ) => Locales . current [ t . hour < 12 ? 'am' : 'pm' ] . toUpperCase ( ) , a : ( t ) => Locales . current [ t . hour < 12 ? 'am' : 'pm' ] , H : ( t ) => t . hour + '' , h : ( t ) => ( ( t . hour % 12 ) || 12 ) + '' , k : ( t ) => ( t . hour + 1 ) + '' , m : ( t ) => t . minute + '' , s : ( t ) => t . second + '' , S : ( t ) => fn . padNumber ( t . millisecond , 3 , 1 ) , HH : ( t ) => fn . padNumber ( t . hour , 2 ) , hh : ( t ) => fn . padNumber ( ( t . hour % 12 ) || 12 , 2 ) , kk : ( t ) => fn . padNumber ( t . hour + 1 , 2 ) , mm : ( t ) => fn . padNumber ( t . minute , 2 ) , ss : ( t ) => fn . padNumber ( t . second , 2 ) , SS : ( t ) => fn . padNumber ( t . millisecond , 3 , 2 ) , SSS : ( t ) => fn . padNumber ( t . millisecond , 3 ) } , { '[' : { start : '[' , startEscape : '\[' , end : ']' , endEscape : '\]' } , "'" : { start : "'" , startEscape : "''" , end : "'" , endEscape : "''" } } ) ;