chrisimcevoy / pyoda-time

A better date and time API for Python
https://pyodatime.org/
Apache License 2.0
1 stars 0 forks source link

We need to talk about `IFormattable.ToString()` #154

Open chrisimcevoy opened 1 month ago

chrisimcevoy commented 1 month ago

152 added a TODO because python's __format__ allows us to specify a format_spec (which in the context of Pyoda Time constitutes a "pattern", standard or otherwise).

What it doesn't allow us to do is specify a CultureInfo, naturally.

Maybe we should implement a def to_string(self, pattern, format_provider) equivalent to IFormattable.ToString()?

chrisimcevoy commented 1 month ago

That said, this needs to fit into a wider discussion around CultureInfo usage and what exactly we want to expose publicly...

chrisimcevoy commented 1 month ago

There are some types like Duration where the tests don't seem to explicitly cover IFormattable.ToString(), or even object.ToString(), explicitly.

I suspect the coverage comes from this section of code in Noda Time.

It's currently a TODO in Pyoda Time, so we'll wanna implement that too if an IFormattable protocol materialises in the codebase.