/*----------------------------------------------------------------------------
   Copyright 2012-2021, Microsoft Research, Daan Leijen

   Licensed under the Apache License, Version 2.0 ("The Licence"). You may not
   use this file except in compliance with the License. A copy of the License
   can be found in the LICENSE file at the root of this distribution.
----------------------------------------------------------------------------*/

// Localization of time formats.
module std/time/localestd/time/locale

// -----------------------------------------------------------
// Time locale
// -----------------------------------------------------------

// The `:time-locale` describes time and date formats for a specific locale.
pub struct time-localestd/time/locale/time-locale: V
  // Language name, for example `en` or `fr-ca`.
  lang-namelang-name: string       : stringstd/core/types/string: V
  day-namesday-names: list<string>       : liststd/core/types/list: V -> V<stringstd/core/types/string: V>
  month-namesmonth-names: list<string>     : liststd/core/types/list: V -> V<stringstd/core/types/string: V>
  month-names-shortmonth-names-short: list<string>: liststd/core/types/list: V -> V<stringstd/core/types/string: V> = month-namesmonth-names: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(fnfn: (m : string) -> string(mm: string) { mm: string.firststd/core/sslice/first: (s : string, n : ? int) -> sslice(3literal: int
dec = 3
hex8 = 0x03
bit8 = 0b00000011
).stringstd/core/sslice/string: (slice : sslice) -> string }) day-names-shortday-names-short: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> = day-namesday-names: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(fnfn: (m : string) -> string(mm: string) { mm: string.firststd/core/sslice/first: (s : string, n : ? int) -> sslice(3literal: int
dec = 3
hex8 = 0x03
bit8 = 0b00000011
).stringstd/core/sslice/string: (slice : sslice) -> string }) day-names-minday-names-min: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> = day-namesday-names: list<string>.mapstd/core/list/map: (xs : list<string>, f : (string) -> string) -> list<string>(fnfn: (m : string) -> string(mm: string) { mm: string.firststd/core/sslice/first: (s : string, n : ? int) -> sslice(2literal: int
dec = 2
hex8 = 0x02
bit8 = 0b00000010
).stringstd/core/sslice/string: (slice : sslice) -> string }) format-tformat-t: string : stringstd/core/types/string: V = "HH:mm"literal: string
count= 5
format-ttformat-tt: string : stringstd/core/types/string: V = "HH:mm:ss"literal: string
count= 8
format-lformat-l: string : stringstd/core/types/string: V = "YYYY-MM-DD"literal: string
count= 10
format-llformat-ll: string : stringstd/core/types/string: V = "D MMMM YYYY"literal: string
count= 11
format-lllformat-lll: string : stringstd/core/types/string: V = "D MMMM YYYY t"literal: string
count= 13
format-llllformat-llll: string : stringstd/core/types/string: V = "dddd D MMMM YYYY t"literal: string
count= 18
// English time locale (`en`) pub val time-locale-enstd/time/locale/time-locale-en: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "en"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Monday"literal: string
count= 6
,"Tuesday"literal: string
count= 7
,"Wednesday"literal: string
count= 9
,"Thursday"literal: string
count= 8
,"Friday"literal: string
count= 6
,"Saturday"literal: string
count= 8
,"Sunday"literal: string
count= 6
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"January"literal: string
count= 7
,"February"literal: string
count= 8
,"March"literal: string
count= 5
,"April"literal: string
count= 5
,"May"literal: string
count= 3
,"June"literal: string
count= 4
,"July"literal: string
count= 4
,"August"literal: string
count= 6
,"September"literal: string
count= 9
,"October"literal: string
count= 7
,"November"literal: string
count= 8
,"December"literal: string
count= 8
]std/core/types/Nil: forall<a> list<a>, format-t = "h:mmaa"literal: string
count= 6
, format-tt = "h:mm:ssaa"literal: string
count= 9
, format-l = "MM/DD/YYYY"literal: string
count= 10
, format-llll = "dddd, D MMMM YYYY t"literal: string
count= 19
) // ISO English time locale (`en-iso`). Uses English names for // months and days but displays numeric dates and times using unambigious ISO format. pub val time-locale-en-isostd/time/locale/time-locale-en-iso: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "en-iso"literal: string
count= 6
, day-names = time-locale-enstd/time/locale/time-locale-en: time-locale.day-namesstd/time/locale/time-locale/day-names: (time-locale) -> list<string>, month-names = time-locale-enstd/time/locale/time-locale-en: time-locale.month-namesstd/time/locale/time-locale/month-names: (time-locale) -> list<string>, format-lll = "D MMMM YYYY, tt"literal: string
count= 15
, format-llll = "dddd, D MMMM YYYY, tt"literal: string
count= 21
) // French time locale (`fr`) pub val time-locale-frstd/time/locale/time-locale-fr: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "fr"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"lundi"literal: string
count= 5
,"mardi"literal: string
count= 5
,"mercredi"literal: string
count= 8
,"jeudi"literal: string
count= 5
,"vendredi"literal: string
count= 8
,"samedi"literal: string
count= 6
,"dimanche"literal: string
count= 8
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"janvier"literal: string
count= 7
,"f\233vrier"literal: string
count= 7
,"mars"literal: string
count= 4
,"avril"literal: string
count= 5
,"mai"literal: string
count= 3
,"juin"literal: string
count= 4
,"juillet"literal: string
count= 7
,"ao\251t"literal: string
count= 4
,"septembre"literal: string
count= 9
,"octobre"literal: string
count= 7
,"novembre"literal: string
count= 8
,"d\233cembre"literal: string
count= 8
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"janv."literal: string
count= 5
,"f\233vr."literal: string
count= 5
,"mars"literal: string
count= 4
,"avr."literal: string
count= 4
,"mai"literal: string
count= 3
,"juin"literal: string
count= 4
,"juil."literal: string
count= 5
,"ao\251t"literal: string
count= 4
,"sept."literal: string
count= 5
,"oct."literal: string
count= 4
,"nov."literal: string
count= 4
,"d\233c."literal: string
count= 4
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"lun."literal: string
count= 4
,"mar."literal: string
count= 4
,"mer."literal: string
count= 4
,"jeu."literal: string
count= 4
,"ven."literal: string
count= 4
,"sam."literal: string
count= 4
,"dim."literal: string
count= 4
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Lu"literal: string
count= 2
,"Ma"literal: string
count= 2
,"Me"literal: string
count= 2
,"Je"literal: string
count= 2
,"Ve"literal: string
count= 2
,"Sa"literal: string
count= 2
,"Di"literal: string
count= 2
]std/core/types/Nil: forall<a> list<a>, format-l = "DD/MM/YYYY"literal: string
count= 10
) // German time locale (`de`) pub val time-locale-destd/time/locale/time-locale-de: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "de"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Montag"literal: string
count= 6
,"Dienstag"literal: string
count= 8
,"Mittwoch"literal: string
count= 8
,"Donnerstag"literal: string
count= 10
,"Freitag"literal: string
count= 7
,"Samstag"literal: string
count= 7
,"Sonntag"literal: string
count= 7
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Januar"literal: string
count= 6
,"Februar"literal: string
count= 7
,"M\228rz"literal: string
count= 4
,"April"literal: string
count= 5
,"Mai"literal: string
count= 3
,"Juni"literal: string
count= 4
,"Juli"literal: string
count= 4
,"August"literal: string
count= 6
,"September"literal: string
count= 9
,"Oktober"literal: string
count= 7
,"November"literal: string
count= 8
,"Dezember"literal: string
count= 8
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Jan."literal: string
count= 4
,"Febr."literal: string
count= 5
,"Mrz."literal: string
count= 4
,"Apr."literal: string
count= 4
,"Mai"literal: string
count= 3
,"Jun."literal: string
count= 4
,"Jul."literal: string
count= 4
,"Aug."literal: string
count= 4
,"Sept."literal: string
count= 5
,"Okt."literal: string
count= 4
,"Nov."literal: string
count= 4
,"Dez."literal: string
count= 4
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Mo."literal: string
count= 3
,"Di."literal: string
count= 3
,"Mi."literal: string
count= 3
,"Do."literal: string
count= 3
,"Fr."literal: string
count= 3
,"Sa."literal: string
count= 3
,"So."literal: string
count= 3
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Mo"literal: string
count= 2
,"Di"literal: string
count= 2
,"Mi"literal: string
count= 2
,"Do"literal: string
count= 2
,"Fr"literal: string
count= 2
,"Sa"literal: string
count= 2
,"So"literal: string
count= 2
]std/core/types/Nil: forall<a> list<a>, format-l = "DD.MM.YYYY"literal: string
count= 10
, format-ll = "D. MMMM YYYY"literal: string
count= 12
, format-lll = "D. MMMM YYYY t"literal: string
count= 14
, format-llll = "dddd, D. MMMM YYYY t"literal: string
count= 20
) // Spanish time locale (`es`) pub val time-locale-esstd/time/locale/time-locale-es: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "es"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"lunes"literal: string
count= 5
,"martes"literal: string
count= 6
,"mi\233rcoles"literal: string
count= 9
,"jueves"literal: string
count= 6
,"viernes"literal: string
count= 7
,"s\225bado"literal: string
count= 6
,"domingo"literal: string
count= 7
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"enero"literal: string
count= 5
,"febrero"literal: string
count= 7
,"marzo"literal: string
count= 5
,"abril"literal: string
count= 5
,"mayo"literal: string
count= 4
,"junio"literal: string
count= 5
,"julio"literal: string
count= 5
,"agosto"literal: string
count= 6
,"septiembre"literal: string
count= 10
,"octubre"literal: string
count= 7
,"noviembre"literal: string
count= 9
,"diciembre"literal: string
count= 9
]std/core/types/Nil: forall<a> list<a>, format-t = "H:mm"literal: string
count= 4
, format-tt = "H:mm:ss"literal: string
count= 7
, format-l = "DD/MM/YYYY"literal: string
count= 10
, format-ll = "D 'de' MMMM 'de' YYYY"literal: string
count= 21
, format-lll = "D 'de' MMMM 'de' YYYY H:mm"literal: string
count= 26
, format-llll = "dddd, D 'de' MMMM 'de' YYYY H:mm"literal: string
count= 32
) // Dutch time locale (`nl`) pub val time-locale-nlstd/time/locale/time-locale-nl: time-locale : time-localestd/time/locale/time-locale: V = Time-locale( "nl"literal: string
count= 2
, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"maandag"literal: string
count= 7
,"dinsdag"literal: string
count= 7
,"woensdag"literal: string
count= 8
,"donderdag"literal: string
count= 9
,"vrijdag"literal: string
count= 7
,"zaterdag"literal: string
count= 8
,"zondag"literal: string
count= 6
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"januari"literal: string
count= 7
,"februari"literal: string
count= 8
,"maart"literal: string
count= 5
,"april"literal: string
count= 5
,"mei"literal: string
count= 3
,"juni"literal: string
count= 4
,"juli"literal: string
count= 4
,"augustus"literal: string
count= 8
,"september"literal: string
count= 9
,"oktober"literal: string
count= 7
,"november"literal: string
count= 8
,"december"literal: string
count= 8
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"jan"literal: string
count= 3
,"feb"literal: string
count= 3
,"mrt"literal: string
count= 3
,"apr"literal: string
count= 3
,"mei"literal: string
count= 3
,"jun"literal: string
count= 3
,"jul"literal: string
count= 3
,"aug"literal: string
count= 3
,"sep"literal: string
count= 3
,"okt"literal: string
count= 3
,"nov"literal: string
count= 3
,"dec"literal: string
count= 3
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"ma."literal: string
count= 3
,"di."literal: string
count= 3
,"wo."literal: string
count= 3
,"do."literal: string
count= 3
,"vr."literal: string
count= 3
,"za."literal: string
count= 3
,"zo."literal: string
count= 3
]std/core/types/Nil: forall<a> list<a>, [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>"Ma"literal: string
count= 2
,"Di"literal: string
count= 2
,"Wo"literal: string
count= 2
,"Do"literal: string
count= 2
,"Vr"literal: string
count= 2
,"Za"literal: string
count= 2
,"Zo"literal: string
count= 2
]std/core/types/Nil: forall<a> list<a>, format-l = "DD-MM-YYYY"literal: string
count= 10
) val localesstd/time/locale/locales: list<time-locale> = [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a> // from most specific (``en-GB`` to least specific ``en``) time-locale-en-isostd/time/locale/time-locale-en-iso: time-locale, time-locale-destd/time/locale/time-locale-de: time-locale,time-locale-enstd/time/locale/time-locale-en: time-locale, time-locale-esstd/time/locale/time-locale-es: time-locale,time-locale-frstd/time/locale/time-locale-fr: time-locale, time-locale-nlstd/time/locale/time-locale-nl: time-locale ]std/core/types/Nil: forall<a> list<a> // Return a builtin locale given a locale string (e.g. ``en-GB``, ``es``); // Use `time-locale-iso` if no particular match is found. // Supports ``de``,``en``,``es``,``fr``,``nl`` and ``en-iso``. pub fun get-time-localestd/time/locale/get-time-locale: (locale : string) -> time-locale( localelocale: string : stringstd/core/types/string: V )result: -> total time-locale : time-localestd/time/locale/time-locale: V val resres: maybe<time-locale> = localesstd/time/locale/locales: list<time-locale>.findstd/core/list/find: (xs : list<time-locale>, pred : (time-locale) -> bool) -> maybe<time-locale> fnfn: (l : time-locale) -> bool(ll: time-locale) localelocale: string.starts-withstd/core/sslice/starts-with: (s : string, pre : string) -> maybe<sslice>(ll: time-locale.lang-namestd/time/locale/time-locale/lang-name: (time-locale) -> string).is-juststd/core/types/is-just: (maybe : maybe<sslice>) -> bool resres: maybe<time-locale>.defaultstd/core/maybe/default: (m : maybe<time-locale>, nothing : time-locale) -> time-locale(time-locale-en-isostd/time/locale/time-locale-en-iso: time-locale)