Closed woylie closed 3 years ago
Thanks for the report. Should be possible, I will take a look over the weekend. Is that is workable from your timeline?
I can definitely support open intervals as parameters but the return string may be something like " – Jan 1, 2020"
since the interval formats from CLDR typically have a space (or non-breaking space) either side of the symbol. And I can't think of a heuristic that would consistently deal with that in all locales.
Would you be ok in that case?
Thanks for the quick reply. I can live with " – Jan 1, 2020"
, I would just pipe the end result into Strim.trim/1
. This is not critical for us, I'm not in a hurry.
Hmmmm, I think I can do String.trim_leading/1
and String.trim_trailing/1
appropriately without creating any issues so I'll go with that and let you know when I'm done.
Sorry for the delay. I have just now published ex_cldr_dates_times version 2.9.0 with the following changelog entry:
nil
. This will produce an open-ended interval. Only one side of the interval can be nil
. Thanks to @woylie for the request. Closes #23. iex> Cldr.Date.Interval.to_string ~D[2020-01-01], nil, MyApp.Cldr,
...> format: :short
{:ok, "1/1/20 –"}
iex> Cldr.Time.Interval.to_string ~U[2020-01-01 00:00:00.0Z], nil, MyApp.Cldr,
...> format: :long, style: :flex
{:ok, "12:00:00 AM UTC –"}
iex> Cldr.DateTime.Interval.to_string ~U[2020-01-01 00:00:00.0Z], nil, MyApp.Cldr
{:ok, "Jan 1, 2020, 12:00:00 AM –"}
Great, thank you very much!
As far as I can see, there is currently no way to format open intervals to strings. What I need to do is this:
And the same for
DateTime.Interval
andTime.Interval
.Is there an easy to way to get to that output with the existing functions? Would it make sense to modify the
to_string
functions as described?