hubertlepicki

hubertlepicki

Localize date/time/datetime format according to local rules

Coming from Rails, we used to have the feature where we could specify date / time / timestamp formats in our translation files, and then use simple helper function to convert date/time/timestamp to current user’s locales using that template. We were also able to specify variants, say :short date format etc. The procedure is described here: https://guides.rubyonrails.org/i18n.html#adding-date-time-formats

Is there something in Elixir ecosystem, that I am not aware of, that allows us to have similar effect?

I think I could hack something like that myself, using gettext to store format strings, then a custom helper to fetch this string from gettext and format timestamps accordingly, but I was wondering if I missed something that’s doing it (possibly better) already in the ecosystem of libraries?

Marked As Solved

wojtekmach

wojtekmach

Hex Core Team

Check out: https://github.com/kipcole9/cldr_dates_times#date-time-and-datetime-localization-formatting

I haven’t used it yet but this looks really comprehensive.

Also Liked

kip

kip

ex_cldr Core Team

Here are the links to the packages in the ex_cldr family latest release. I can see the benefit to a tighter integration between Gettext and ex_cldr and would welcome any thoughts along those lines.

LostKobrakai

LostKobrakai

I’m using it and it’s really great. With ex_cldr and the cldr database backing it the level of availability and maintenance of formats is just unbeatable compared to any per project database.

hubertlepicki

hubertlepicki

the whole bunch of libraries look like something I can definitely use. I will give it a try, thank you so much for doing it :heart:

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement