ariebovenberg / whenever

⏰ Sensible and typesafe datetimes for Python
https://whenever.rtfd.io
MIT License
362 stars 7 forks source link

consider renaming 'naive()' to 'as_naive()' #61

Closed bxparks closed 4 months ago

bxparks commented 4 months ago

A very minor observation, but other conversion functions have the form:

But conversion to NiaveDateTime is:

Consider changing this to as_naive() for consistency.

ariebovenberg commented 4 months ago

This is intentional (for now 😉 ). Quoting from the docs:

The seemingly inconsistent naming of naive() and the as* methods is intentional. The as* methods preserve the same moment in time, while naive() converts to something else entirely.

ariebovenberg commented 4 months ago

I'll admit that a small "note" block is probably not enough to make this clear. Perhaps a diagram like this (hopefully simplified):

image
bxparks commented 4 months ago

Ah, I missed the note. The diagram definitely helps. Though I think of the other "as_xxx()" as "losing information" as well. They do preserve "timestamp()", but they lose other information.

ariebovenberg commented 4 months ago

Correct, "losing information" is not the right wording. "loses position on the timeline" is perhaps the best way to describe naive() in comparison to methods like as_zoned()

ariebovenberg commented 4 months ago

I've created a follow-up for visualizing classes and their conversions. This includes rationale for the seemingly inconsistent naming. See #69.

The current issue is about the specific method, which will not be changed. Closed.