Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for multiple languages #6

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Config

config :elixir, :time_zone_database, Tz.TimeZoneDatabase
config :date_time_parser, cldr_backend: DateTimeParser.Cldr
config :elixir, :time_zone_database, Tz.TimeZoneDatabase
116 changes: 59 additions & 57 deletions lib/combinators.ex.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,63 @@ defmodule DateTimeParser.Combinators do
@moduledoc false
# credo:disable-for-this-file

@months_map %{
"january" => 1,
"february" => 2,
"march" => 3,
"april" => 4,
"may" => 5,
"june" => 6,
"july" => 7,
"august" => 8,
"september" => 9,
"october" => 10,
"november" => 11,
"december" => 12,
"jan" => 1,
"feb" => 2,
"mar" => 3,
"apr" => 4,
"jun" => 6,
"jul" => 7,
"aug" => 8,
"sept" => 9,
"sep" => 9,
"oct" => 10,
"nov" => 11,
"dec" => 12
}
@cldr_backend Application.compile_env(:date_time_parser, :cldr_backend)
if Code.ensure_loaded?(@cldr_backend) and
Code.ensure_loaded?(Cldr.DateTime) and
Code.ensure_loaded?(Cldr.Calendar) do
@cldr_month_format_wide 4
@cldr_month_format_abbr 3
supported_locales = @cldr_backend.known_locale_names()

@months_map (for month_numeric <- 1..12,
date = Date.new!(2022, month_numeric, 1),
lang <- supported_locales,
lang = to_string(lang),
cldr_format <- [@cldr_month_format_wide, @cldr_month_format_abbr],
reduce: Map.new() do
acc ->
month_str =
date
|> Cldr.DateTime.Formatter.standalone_month(
cldr_format,
lang,
@cldr_backend
)
|> String.downcase()

Map.put(acc, month_str, month_numeric)
end)

@cldr_day_format_wide 4
@cldr_day_format_abbr 1
@cldr_day_format_short 6
@vocal_days (for cldr_format <- [
@cldr_day_format_wide,
@cldr_day_format_abbr,
@cldr_day_format_short
],
lang <- supported_locales,
lang = to_string(lang),
day_numeric <- 1..7,
date = Date.new!(2022, 1, day_numeric),
uniq: true do
date
|> Cldr.DateTime.Formatter.day_name(cldr_format, lang, @cldr_backend)
|> String.downcase()
end)
else
@vocal_days ~w(sunday monday tuesday wednesday thursday friday saturday) ++
~w(sun mon tue tues wed weds thu thur thurs fri sat)
@months_map ~w(january february march april may june july august september october november december)
|> Enum.with_index(1)
|> Enum.reduce(Map.new(), fn {base_month, index}, acc ->
month_abbr = String.slice(base_month, 0..2)

acc
|> Map.put(base_month, index)
|> Map.put(month_abbr, index)
end)
end

def to_integer(value) when is_binary(value), do: String.to_integer(value)
def vocal_month_to_numeric_month(value), do: Map.get(@months_map, value)
Expand Down Expand Up @@ -165,36 +196,6 @@ defmodule DateTimeParser.Combinators do
defparsec(:parse_time, time, inline: true)

## DATE

@days_map %{
"sun" => "Sunday",
"mon" => "Monday",
"tues" => "Tuesday",
"tue" => "Tuesday",
"wed" => "Wednesday",
"weds" => "Wednesday",
"thurs" => "Thursday",
"thur" => "Thursday",
"thu" => "Thursday",
"fri" => "Friday",
"sat" => "Saturday"
}

@vocal_days_long @days_map
|> Map.values()
|> Enum.uniq()
|> Enum.map(&String.downcase/1)
|> Enum.sort_by(&byte_size/1)
|> Enum.reverse()
|> Enum.map(&string/1)

@vocal_days_short @days_map
|> Map.keys()
|> Enum.uniq()
|> Enum.map(&String.downcase/1)
|> Enum.sort_by(&byte_size/1)
|> Enum.reverse()
|> Enum.map(&string/1)
@date_separator [",", ".", "/", "-", " "]

year4 =
Expand Down Expand Up @@ -340,7 +341,8 @@ defmodule DateTimeParser.Combinators do
])

vocal_day =
(@vocal_days_long ++ @vocal_days_short)
@vocal_days
|> Enum.map(&string/1)
|> choice()
|> unwrap_and_tag(:vocal_day)
|> label("vocal day spelled out")
Expand Down
2 changes: 2 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ defmodule DateTimeParser.MixProject do
defp deps() do
[
{:exprof, "~> 0.2.0", only: :bench},
{:ex_cldr_dates_times, "~> 2.0", only: [:dev, :test, :bench]},
{:ex_cldr_calendars, "~> 1.17", only: [:dev, :test, :bench]},
{:kday, "~> 1.0", runtime: false},
{:benchee, "~> 1.0", only: [:bench], runtime: false},
{:tz, "~> 0.24", only: [:dev, :test, :bench], runtime: false},
Expand Down
16 changes: 12 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
%{
"benchee": {:hex, :benchee, "1.1.0", "f3a43817209a92a1fade36ef36b86e1052627fd8934a8b937ac9ab3a76c43062", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}], "hexpm", "7da57d545003165a012b587077f6ba90b89210fd88074ce3c60ce239eb5e6d93"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"certifi": {:hex, :certifi, "2.6.1", "dbab8e5e155a0763eea978c913ca280a6b544bfa115633fa20249c3d396d9493", [:rebar3], [], "hexpm", "524c97b4991b3849dd5c17a631223896272c6b0af446778ba4675a1dff53bb7e"},
"certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"},
"cldr_utils": {:hex, :cldr_utils, "2.19.1", "5a7bcd2f2fd432c548e494e850bba8a9e838f1b10202f682ea1d9809d74eff31", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "fbd10f79363e70f3d893ab21e195f444ca87c2c80120b5911761491da4489620"},
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"},
"credo": {:hex, :credo, "1.6.7", "323f5734350fd23a456f2688b9430e7d517afb313fbd38671b8a4449798a7854", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "41e110bfb007f7eda7f897c10bf019ceab9a0b269ce79f015d54b0dcf4fc7dd3"},
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
"digital_token": {:hex, :digital_token, "0.4.0", "2ad6894d4a40be8b2890aad286ecd5745fa473fa5699d80361a8c94428edcd1f", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a178edf61d1fee5bb3c34e14b0f4ee21809ee87cade8738f87337e59e5e66e26"},
"ex_cldr": {:hex, :ex_cldr, "2.34.0", "50385e1445f33537bea7d24ca7525aa849ccabb3cf88ac41a6d183693116aba7", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.18", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "d026df7d580424ab8daf0d908fd38d3c12e0a63962b495b7faeabd66ab072588"},
"ex_cldr_calendars": {:hex, :ex_cldr_calendars, "1.21.0", "5f3c71a145926cfa7f8691aa3566921957543f635ec345e52282c613e8985ba8", [:mix], [{:calendar_interval, "~> 0.2", [hex: :calendar_interval, repo: "hexpm", optional: true]}, {:ex_cldr_lists, "~> 2.10", [hex: :ex_cldr_lists, repo: "hexpm", optional: true]}, {:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_cldr_units, "~> 3.12", [hex: :ex_cldr_units, repo: "hexpm", optional: true]}, {:ex_doc, "~> 0.21", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8ce8737b70f9c36828324995f96464a1a4c87cf2f76e5868e20662ca31c4098f"},
"ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.14.2", "354b48134faa011d58ae2e89be69b7de607d81fcc74c7ac684c5fb77b20186f5", [:mix], [{:ex_cldr, "~> 2.27", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "c970533103cdc97b1dedc2fead2209c0f5ae0aee0f1e504fdea5be5ee1466cd1"},
"ex_cldr_dates_times": {:hex, :ex_cldr_dates_times, "2.13.1", "bab1284590528b410a8d2488673642f3e3d84c1fa3fa3fbe91569ac4a5016e43", [:mix], [{:calendar_interval, "~> 0.2", [hex: :calendar_interval, repo: "hexpm", optional: true]}, {:ex_cldr_calendars, "~> 1.18", [hex: :ex_cldr_calendars, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.28", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "b3d49035642c6ab7ed8f0f565524cd10d3b25dc57df3edd8ceba5e5c2caa730c"},
"ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.28.0", "506f5d36a2b72a21bbcb6e55dfdc5c3ff7f1c07d65e516461125158d10661beb", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:digital_token, "~> 0.3 or ~> 1.0", [hex: :digital_token, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.34", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, ">= 2.14.2", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "83342ff668aedf3aa5c54b048ce1da0f91317b6596b14880a5f87d45cd1c49d2"},
"earmark_parser": {:hex, :earmark_parser, "1.4.31", "a93921cdc6b9b869f519213d5bc79d9e218ba768d7270d46fdcf1c01bacff9e2", [:mix], [], "hexpm", "317d367ee0335ef037a87e46c91a2269fef6306413f731e8ec11fc45a7efd059"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.29.2", "dfa97532ba66910b2a3016a4bbd796f41a86fc71dd5227e96f4c8581fdf0fdf0", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "6b5d7139eda18a753e3250e27e4a929f8d2c880dd0d460cb9986305dea3e03af"},
"exprintf": {:hex, :exprintf, "0.2.1", "b7e895dfb00520cfb7fc1671303b63b37dc3897c59be7cbf1ae62f766a8a0314", [:mix], [], "hexpm", "20a0e8c880be90e56a77fcc82533c5d60c643915c7ce0cc8aa1e06ed6001da28"},
"exprof": {:hex, :exprof, "0.2.4", "13ddc0575a6d24b52e7c6809d2a46e9ad63a4dd179628698cdbb6c1f6e497c98", [:mix], [{:exprintf, "~> 0.2", [hex: :exprintf, repo: "hexpm", optional: false]}], "hexpm", "0884bcb66afc421c75d749156acbb99034cc7db6d3b116c32e36f32551106957"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"hackney": {:hex, :hackney, "1.17.4", "99da4674592504d3fb0cfef0db84c3ba02b4508bae2dff8c0108baa0d6e0977c", [:rebar3], [{:certifi, "~>2.6.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "de16ff4996556c8548d512f4dbe22dd58a587bf3332e7fd362430a7ef3986b16"},
"hackney": {:hex, :hackney, "1.18.1", "f48bf88f521f2a229fc7bae88cf4f85adc9cd9bcf23b5dc8eb6a1788c662c4f6", [:rebar3], [{:certifi, "~>2.9.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~>6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~>1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~>1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a4ecdaff44297e9b5894ae499e9a070ea1888c84afdd1fd9b7b2bc384950128e"},
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
"kday": {:hex, :kday, "1.0.1", "c9e6d4d4677c1213b23a3e5f478993a55a9c80ca3e1d9f03f7d89f958553d1ee", [:mix], [{:ex_doc, "~> 0.21", [hex: :ex_doc, repo: "hexpm", optional: true]}], "hexpm", "38b9b9a0cbd9973fafc6d7bb78566c9922b32c596c39ebb720687d6a6c55373f"},
Expand All @@ -20,11 +28,11 @@
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"nimble_parsec": {:git, "https://github.com/dashbitco/nimble_parsec.git", "dc1e2278349f4263eee2babd4432b30cff0e9210", []},
"nimble_parsec": {:git, "https://github.com/dashbitco/nimble_parsec.git", "72678dd0c1df07d80c0a851b952986f8972806b5", []},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
"tz": {:hex, :tz, "0.24.0", "a9073f152c5a9d0abeafde57150cd61d9f11faa7fa3710a20e8487ce05c76cee", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:mint, "~> 1.4", [hex: :mint, repo: "hexpm", optional: true]}], "hexpm", "5c08671bb10a56e09371106b08f5c9192449bb22e94a51de063c8c1317317027"},
"tzdata": {:hex, :tzdata, "1.1.0", "72f5babaa9390d0f131465c8702fa76da0919e37ba32baa90d93c583301a8359", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "18f453739b48d3dc5bcf0e8906d2dc112bb40baafe2c707596d89f3c8dd14034"},
"tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
}
28 changes: 28 additions & 0 deletions test/date_time_parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -780,4 +780,32 @@ defmodule DateTimeParserTest do
test_date_error("2017-#{@month}-31", ~s|Could not parse "2017-#{@month}-31"|)
end
end

describe "translated" do
setup do
Application.put_env(:date_time_parser, :cldr_backend, DateTime.Cldr)

on_exit(fn ->
Application.delete_env(:date_time_parser, :cldr_backend)
end)
end

test_parsing(" 01 Lut 2013", "2013-02-01")
test_parsing(" 03 Sty 2013 10:15:26 -0800", "2013-01-03T18:15:26Z", to_utc: true)
test_parsing(" 11 Lut 2013", "2013-02-11")
test_parsing(" 11 Sty 2013 13:26:55 -0800", "2013-01-11T21:26:55Z", to_utc: true)
test_parsing(" 24 Wrz 2013", "2013-09-24")
test_parsing("01-Lut-18", "2018-02-01")
test_parsing("01-Lip", "2019-07-01", assume_date: ~D[2019-01-05])
test_parsing("01-Lip-18", "2018-07-01")
test_parsing("Sobota 01 Styczeń 2017 09:22:46 AM", "2017-01-01T09:22:46")
test_parsing("Sob 01 Sty 2017 10:11:02 PM", "2017-01-01T22:11:02")
test_parsing("Czw Sie 09 2018 17:13:43 GMT+0000 (UTC)", "2018-08-09T17:13:43Z")
test_parsing("Czw Lut 08 00:24:33 2018", "2018-02-08T00:24:33")
test_parsing("Czw Lip 5 12:19:56 2018", "2018-07-05T12:19:56")
test_parsing("Wto Lip 31 06:44:39 2018", "2018-07-31T06:44:39")
test_parsing("Czwartek 30 Sierpień 2018 11:31:18 AM", "2018-08-30T11:31:18")
test_parsing("Wtorek 11 Lipiec 2017 1:43:46 PM", "2017-07-11T13:43:46")
test_parsing(~s|"Wtorek, Listopad 29, 2016"|, "2016-11-29")
end
end
9 changes: 9 additions & 0 deletions test/support/cldr.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule DateTimeParser.Cldr do
@moduledoc """
Cldr module used in tests
"""
use Cldr,
locales: ["en", "pl"],
default_locale: "en",
providers: [Cldr.Calendar, Cldr.DateTime, Cldr.Number]
end