import type { Quarter } from '../../../../types' ; import type { Localize , LocalizeFn } from '../../../types' ; import buildLocalizeFn from '../../../_lib/buildLocalizeFn/index' ; const eraValues = { narrow : [ 'B' , 'A' ] as const , abbreviated : [ 'BC' , 'AD' ] as const , wide : [ 'Before Christ' , 'Anno Domini' ] as const , } ; const quarterValues = { narrow : [ '1' , '2' , '3' , '4' ] as const , abbreviated : [ 'Q1' , 'Q2' , 'Q3' , 'Q4' ] as const , wide : [ '1st quarter' , '2nd quarter' , '3rd quarter' , '4th quarter' ] as const , } ; const monthValues = { narrow : [ 'J' , 'F' , 'M' , 'A' , 'M' , 'J' , 'J' , 'A' , 'S' , 'O' , 'N' , 'D' ] as const , abbreviated : [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' , ] as const , wide : [ 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' , ] as const , } ; const dayValues = { narrow : [ 'S' , 'M' , 'T' , 'W' , 'T' , 'F' , 'S' ] as const , short : [ 'Su' , 'Mo' , 'Tu' , 'We' , 'Th' , 'Fr' , 'Sa' ] as const , abbreviated : [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] as const , wide : [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' , ] as const , } ; const dayPeriodValues = { narrow : { am : 'a' , pm : 'p' , midnight : 'mi' , noon : 'n' , morning : 'morning' , afternoon : 'afternoon' , evening : 'evening' , night : 'night' , } , abbreviated : { am : 'AM' , pm : 'PM' , midnight : 'midnight' , noon : 'noon' , morning : 'morning' , afternoon : 'afternoon' , evening : 'evening' , night : 'night' , } , wide : { am : 'a.m.' , pm : 'p.m.' , midnight : 'midnight' , noon : 'noon' , morning : 'morning' , afternoon : 'afternoon' , evening : 'evening' , night : 'night' , } , } ; const formattingDayPeriodValues = { narrow : { am : 'a' , pm : 'p' , midnight : 'mi' , noon : 'n' , morning : 'in the morning' , afternoon : 'in the afternoon' , evening : 'in the evening' , night : 'at night' , } , abbreviated : { am : 'AM' , pm : 'PM' , midnight : 'midnight' , noon : 'noon' , morning : 'in the morning' , afternoon : 'in the afternoon' , evening : 'in the evening' , night : 'at night' , } , wide : { am : 'a.m.' , pm : 'p.m.' , midnight : 'midnight' , noon : 'noon' , morning : 'in the morning' , afternoon : 'in the afternoon' , evening : 'in the evening' , night : 'at night' , } , } ; const ordinalNumber = ( dirtyNumber , _options ) => { const number = Number ( dirtyNumber ) ; const rem100 = number % 100 ; if ( rem100 > 20 || rem100 < 10 ) { switch ( rem100 % 10 ) { case 1 : return number + 'st' ; case 2 : return number + 'nd' ; case 3 : return number + 'rd' ; } } return number + 'th' ; } ; const localize = { ordinalNumber , era : buildLocalizeFn ( { values : eraValues , defaultWidth : 'wide' , } ) , quarter : buildLocalizeFn ( { values : quarterValues , defaultWidth : 'wide' , argumentCallback : ( quarter ) => ( quarter - 1 ) as Quarter , } ) , month : buildLocalizeFn ( { values : monthValues , defaultWidth : 'wide' , } ) , day : buildLocalizeFn ( { values : dayValues , defaultWidth : 'wide' , } ) , dayPeriod : buildLocalizeFn ( { values : dayPeriodValues , defaultWidth : 'wide' , formattingValues : formattingDayPeriodValues , defaultFormattingWidth : 'wide' , } ) , } ; export default localize ;