Open synotna opened 8 years ago
Yes I could see that being very useful. I'd welcome a PR
I'm still concerned about adding the locale to Arrow
. Generally, Python objects do not store their formatting options as part of the object, but instead are specified at the time of formatting.
If we extended Arrow.__format__
to include a locale in the format string itself, would that work for you @synotna? Something like:
f'My name is {name} and my birthday is {birthday:MMMM-YYYY#fr_ca}'
# (We'd need to research if `#` is a good choice for this)
A great side effect of how Arrow's formatting is implemented, is that it can be used like any other type with regular string formatting, e.g.
'My name is {name} and my birthday is {birthday:MMMM-YYYY}'.format(**myself)
However, if I want the Arrow formatting to be in a specific locale, I have a problem. Even though I can specifiy locale with .get(), the locale is only used for parsing but not stored, and I have no way of providing arrow with the locale when calling format above.
My quick & dirty solution, which may be helpful for others with the same problem, is:
Would, or have you considered storing & using the locale in as part of regular Arrow?