Open ghiculescu opened 7 years ago
Interesting concept, there are only a few I18n defined date formats, but it should be possible to reorder emitters based on the format in I18n, if the current emitter pattern matches a format.
i.e.
I18n.format = 'en-AU'
Date.new(2017, 3, 13).l_stamp("13 Mar") # => "13 Mar"
Date.new(2017, 3, 13).l_stamp("Mar 13") # => "13 Mar"
Date.new(2017, 3, 13).l_stamp("March 13") # => "March 13" -- Doesn't match a format
Date.new(2017, 3, 13).l_stamp("2017-31-12") # => "2017-12-31"
Date.new(2017, 3, 13).l_stamp("March 13, 2013") # => "13 March, 2017"
Date.new(2017, 3, 13).l_stamp("March 13 2013") # => "March 13 2017" -- Doesn't match a format
For the lines that don't match a format, the ordering wasn't changed.
Would something like this suffice?
Yeah I think that would work.
Here's a problem I'm coming up against a lot:
In the US, the dates should show up as "03/13 - 03/19". Another example is in the page title:
l_stamp
isn't helping with this yet, because while it would translate the "Mar" to something else if I was in France, it won't change the format that stamp is given.Rails has support for this built in, you can customise your localisation formats http://guides.rubyonrails.org/i18n.html#adding-date-time-formats and then you can call
I18n.l(Date.new(2017, 3, 13), format: :short)
(in fact, this one's a builtin).So the challenge is designing an API for
l_stamp
that will let us do both. My goal is to be able to do:I18n.l(Date.new(2013, 3, 13), format: :short, locale: 'fr')
does what I want, so the challenge is basically if we can do this but with stamp-like formats.