bitwalker / bitwalker/timex

Location aware formatting?

Open
#702 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Elixir
Stars
1.8k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

Hi! I can't find on the documentation if Timex is capable of doing something like this:

```js
new Date().toLocaleString('en', {year: 'numeric', month: 'numeric', day: 'numeric'})
// >> '1/20/2022'
new Date().toLocaleString('pt-BR', {year: 'numeric', month: 'numeric', day: 'numeric'})
// >> '20/01/2022'
```

I see that many directives are documented in the [`Timex.Format.DateTime.Formatters.Default`](https://hexdocs.pm/timex/Timex.Format.DateTime.Formatters.Default.html) page, but I can't find a non-hard-coded way of defining a short date formats like this that are aware of the user's locale.

PS.: I've seen people in the community recommending [`ex_cldr`](https://github.com/elixir-cldr/cldr) and [`ex_cldr_dates_times`](https://github.com/elixir-cldr/cldr_dates_times), but the locales are not "compatible" with Timex. For instance, there's no **pt-BR** locale, only **pt** and **pt-PT** (https://github.com/elixir-cldr/cldr/issues/42), the first one being the "correct" format according to the spec they are following, which makes interop kind of a PITA tbh since we are storing Timex locales.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.