From 91b1b75e1eeebac66ef14f8c0fd4830d88ce5169 Mon Sep 17 00:00:00 2001 From: vt Date: Tue, 21 Mar 2017 10:28:44 +0300 Subject: [PATCH 1/2] Add Russian locale --- src/Date/Extra/Config/Config_ru_ru.elm | 33 ++++++++++ src/Date/Extra/Config/Configs.elm | 2 + src/Date/Extra/I18n/I_ru_ru.elm | 85 ++++++++++++++++++++++++++ tests/Date/Extra/ConfigTests.elm | 7 +++ tests/Date/Extra/FormatTests.elm | 5 ++ 5 files changed, 132 insertions(+) create mode 100644 src/Date/Extra/Config/Config_ru_ru.elm create mode 100644 src/Date/Extra/I18n/I_ru_ru.elm diff --git a/src/Date/Extra/Config/Config_ru_ru.elm b/src/Date/Extra/Config/Config_ru_ru.elm new file mode 100644 index 0000000..d6857d2 --- /dev/null +++ b/src/Date/Extra/Config/Config_ru_ru.elm @@ -0,0 +1,33 @@ +module Date.Extra.Config.Config_ru_ru exposing (..) + +{-| This is the default russian config for formatting dates. + +@docs config + +Copyright (c) 2016 Slava Turchaninov +-} + +import Date +import Date.Extra.Config as Config +import Date.Extra.I18n.I_ru_ru as Russian + + +{-| Config for ru-ru. -} +config : Config.Config +config = + { i18n = + { dayShort = Russian.dayShort + , dayName = Russian.dayName + , monthShort = Russian.monthShort + , monthName = Russian.monthName + , dayOfMonthWithSuffix = Russian.dayOfMonthWithSuffix + } + , format = + { date = "%d/%m/%Y" -- d/M/YYY + , longDate = "%A, %B %d, %Y" -- dddd, MMMM dd, yyyy + , time = "%H:%M" -- H:mm tt + , longTime = "%H:%M:%S" -- H:mm:ss + , dateTime = "%d/%m/%Y %H:%M" -- date + time + , firstDayOfWeek = Date.Mon + } + } diff --git a/src/Date/Extra/Config/Configs.elm b/src/Date/Extra/Config/Configs.elm index f23fb4f..1c9518d 100644 --- a/src/Date/Extra/Config/Configs.elm +++ b/src/Date/Extra/Config/Configs.elm @@ -27,6 +27,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_ru_ru as Config_ru_ru {-| Built in configurations. -} @@ -44,6 +45,7 @@ configs = , ("pt_br", Config_pt_br.config) , ("et_ee", Config_et_ee.config) , ("ja_jp", Config_ja_jp.config) + , ("ru_ru", Config_ru_ru.config) ] diff --git a/src/Date/Extra/I18n/I_ru_ru.elm b/src/Date/Extra/I18n/I_ru_ru.elm new file mode 100644 index 0000000..da6ff71 --- /dev/null +++ b/src/Date/Extra/I18n/I_ru_ru.elm @@ -0,0 +1,85 @@ +module Date.Extra.I18n.I_ru_ru exposing (..) + +{-| Russian values for day and month names. + +@docs dayShort +@docs dayName +@docs monthShort +@docs monthName +@docs dayOfMonthWithSuffix + +Copyright (c) 2017 Slava Turchaninov +-} + + +import Date exposing (Day (..), Month (..)) +import String exposing (padLeft) + + +{-| Day short name. -} +dayShort : Day -> String +dayShort day = + case day of + Mon -> "Пн" + Tue -> "Вт" + Wed -> "Ср" + Thu -> "Чт" + Fri -> "Пт" + Sat -> "Сб" + Sun -> "Вс" + + +{-| Day full name. -} +dayName : Day -> String +dayName day = + case day of + Mon -> "Понедельник" + Tue -> "Вторник" + Wed -> "Среда" + Thu -> "Четверг" + Fri -> "Пятница" + Sat -> "Суббота" + Sun -> "Воскресенье" + + +{-| Month short name. -} +monthShort : Month -> String +monthShort month = + case month of + Jan -> "Янв" + Feb -> "Фев" + Mar -> "Мар" + Apr -> "Апр" + May -> "Май" + Jun -> "Июн" + Jul -> "Июл" + Aug -> "Авг" + Sep -> "Сен" + Oct -> "Окт" + Nov -> "Ноя" + Dec -> "Дек" + + +{-| Month full name. -} +monthName : Month -> String +monthName month = + case month of + Jan -> "Январь" + Feb -> "Февраль" + Mar -> "Март" + Apr -> "Апрель" + May -> "Май" + Jun -> "Июнь" + Jul -> "Июль" + Aug -> "Август" + Sep -> "Сентябрь" + Oct -> "Октябрь" + Nov -> "Ноябрь" + Dec -> "Декабрь" + + +{-| Just convert to string-} +dayOfMonthWithSuffix : Bool -> Int -> String +dayOfMonthWithSuffix pad day = + case day of + _ -> (toString day) diff --git a/tests/Date/Extra/ConfigTests.elm b/tests/Date/Extra/ConfigTests.elm index 6d675f2..c6d2b0c 100644 --- a/tests/Date/Extra/ConfigTests.elm +++ b/tests/Date/Extra/ConfigTests.elm @@ -15,6 +15,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_ru_ru as Config_ru_ru import Date.Extra.Config.Configs as Configs @@ -29,6 +30,7 @@ config_nl_nl = Config_nl_nl.config config_pt_br = Config_pt_br.config config_et_ee = Config_et_ee.config config_ja_jp = Config_ja_jp.config +config_ru_ru = Config_ru_ru.config tests : Test @@ -99,4 +101,9 @@ tests = Expect.equal config_ja_jp.format (Configs.getConfig "ja_jp").format + , test "getConfig ru_ru" <| + \() -> + Expect.equal + config_ru_ru.format + (Configs.getConfig "ru_ru").format ] diff --git a/tests/Date/Extra/FormatTests.elm b/tests/Date/Extra/FormatTests.elm index 2c29614..5b56b3c 100644 --- a/tests/Date/Extra/FormatTests.elm +++ b/tests/Date/Extra/FormatTests.elm @@ -24,6 +24,7 @@ import Date.Extra.Config.Config_nl_nl as Config_nl_nl import Date.Extra.Config.Config_pt_br as Config_pt_br import Date.Extra.Config.Config_et_ee as Config_et_ee import Date.Extra.Config.Config_ja_jp as Config_ja_jp +import Date.Extra.Config.Config_ru_ru as Config_ru_ru import Date.Extra.Period as DPeriod exposing (Period (Hour)) @@ -38,6 +39,7 @@ config_nl_nl = Config_nl_nl.config config_pt_br = Config_pt_br.config config_et_ee = Config_et_ee.config config_ja_jp = Config_ja_jp.config +config_ru_ru = Config_ru_ru.config tests : Test @@ -185,6 +187,9 @@ formatConfigTestCases = , ("Config_et_ee format idiom", "teisipäev (5.) 05 august 2014", config_et_ee, dayDayIdiomMonth, aTestTime5) , ("Config_ja_jp day idiom", "2014/8/5", config_ja_jp, config_ja_jp.format.date, aTestTime5) , ("Config_ja_jp format idiom", "火曜日 (5) 05 8月 2014", config_ja_jp, dayDayIdiomMonth, aTestTime5) + , ("Config_ru_ru day idiom", "05/08/2014", config_ru_ru, config_ru_ru.format.date, aTestTime5) + , ("Config_ru_ru format idiom", "Вторник (5) 05 Август 2014", config_ru_ru, dayDayIdiomMonth, aTestTime5) + , ("Config_ru_ru time idiom", "05:53", config_ru_ru, config_ru_ru.format.time, aTestTime5) ] From 0c31e6f0af64b6869d23c029fd841620c535e6c6 Mon Sep 17 00:00:00 2001 From: vt Date: Sun, 26 Mar 2017 22:27:29 +0300 Subject: [PATCH 2/2] Update package exported modules --- elm-package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/elm-package.json b/elm-package.json index 9b17550..1df0c62 100644 --- a/elm-package.json +++ b/elm-package.json @@ -25,6 +25,7 @@ "Date.Extra.I18n.I_pt_br", "Date.Extra.I18n.I_et_ee", "Date.Extra.I18n.I_ja_jp", + "Date.Extra.I18n.I_ru_ru", "Date.Extra.Config.Configs", "Date.Extra.Config.Config_en_au", "Date.Extra.Config.Config_en_us", @@ -37,6 +38,7 @@ "Date.Extra.Config.Config_pt_br", "Date.Extra.Config.Config_et_ee", "Date.Extra.Config.Config_ja_jp", + "Date.Extra.Config.Config_ru_ru", "Date.Extra.Field" ], "dependencies": {