Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bxparks opened this issue Feb 22, 2024 · 5 comments
Closed

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

bxparks opened this issue Feb 22, 2024 · 5 comments
Labels
discussion Discussion is needed before proceeding

Comments

@bxparks
Copy link

bxparks commented Feb 22, 2024

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

  • as_utc()
  • as_offset
  • as_zoned()
  • as_local()

But conversion to NiaveDateTime is:

  • naive()

Consider changing this to as_naive() for consistency.

@ariebovenberg
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

bxparks commented Feb 22, 2024

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
Copy link
Owner

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 ariebovenberg added the discussion Discussion is needed before proceeding label Feb 22, 2024
@ariebovenberg
Copy link
Owner

ariebovenberg commented Feb 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion is needed before proceeding
Projects
None yet
Development

No branches or pull requests

2 participants