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

Improve naive/aware DateTime objects and documentation #293

Closed
jenstroeger opened this issue Jul 22, 2017 · 1 comment
Closed

Improve naive/aware DateTime objects and documentation #293

jenstroeger opened this issue Jul 22, 2017 · 1 comment

Comments

@jenstroeger
Copy link
Contributor

I think it would help to clarify in the documentation that a deserialized datetime object is by default aware (i.e. its tzinfo attribute is set to a timezone object provided by the pytz non-standard library) rather than being naive (i.e. its tzinfo attribute is None).

In this context, normalizing while deserializing an aware datetime into a naive datetime would be useful for those applications which operate purely on naive datetime objects. For example, deserializing a string with +00:00 as a timezone might simply strip tzinfo, whereas other offsets ought to be added to a naive datetime using a timedelta derived from the offset.

@tseaver
Copy link
Member

tseaver commented May 20, 2024

@jenstroeger Hmm, the current docs seem to me to make it clear that naive datetimes get a timezone applied using the default_tzinfo attribute. Users who want to suppress that conversion need to pass tz_info=None when constructing the schema node / type. E.g.:

import colander

class Example(colander.Schema):
    naive_stamp = colander.SchemaNode(
        colander.DateTime(default_tzinfo=None),
    )

Please feel free to reopen if I've missed the point here.

@tseaver tseaver closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants