Calendar default format for strftime

Is there a way to set a default format for Calendar.strftime/3?
I see in the documentation you can give a :preferred_datetime, :preferred_date or :preferred_time option that will then be used for %c, %x or %X respectively.
But I was wondering if these could be set in config for example, globally.

I don’t think so, but you could always wrap it in your own API. ex_cldr can iirc also give you strftime options.

1 Like

That’s a shame.
I would prefer not to add a dependency just for that, own module will have to do.

Thanks again, and a happy, healthy and prosperous 2025.

Tbh given it’s not obvious where such configuration might come from I don’t think it’s that bad that elixir doesn’t provide one ootb. The few other configurations elixir core uses are imo much more clear cut to justify global config using the app env

Oh, I don’t know, you specify what module you use for the :time_zone_database.
But it’s not like we have no options without that.

We do, but I’d argue having multiple time zone databases screams chaos, while different concurrent formats in use sound more like a default requirement.

I think most cases will have 1 format, and setting a default format does not exclude giving the format on the function call.
In fact you still have to use one of the predefined qualifiers to select the predefined format.