pydantic-core icon indicating copy to clipboard operation
pydantic-core copied to clipboard

naive and aware constraints on datetime types

Open samuelcolvin opened this issue 2 years ago • 4 comments

Should be fairly easy since speedate gives offset as optional.

@antonagestam said he might be able to work on this, see https://github.com/pydantic/pydantic/discussions/3477#discussioncomment-3771452

samuelcolvin avatar Sep 30 '22 11:09 samuelcolvin

A related note: I believe the "date-time" format of JSON Schema is considered timezone-aware. That means that the aware type should have it, but the naive should not.

It also means it's slightly weird that datetime.datetime has it but without enforcing it, IMO. It might be worth putting in some time into documenting these things, and perhaps recommending usage of aware over datetime.datetime?

antonagestam avatar Sep 30 '22 14:09 antonagestam

Totally agree, plan is to rewrite the documentation completely - on my long list of things to do.

samuelcolvin avatar Sep 30 '22 14:09 samuelcolvin

@samuelcolvin Cool, that's good to know! 👍

antonagestam avatar Sep 30 '22 14:09 antonagestam

Just to be clear, speedate is part of the pydantic org, and I built it specifically for pydantic-core, so we can change it if required.

samuelcolvin avatar Sep 30 '22 14:09 samuelcolvin

I'm taking an initial look at this. Just setting up and familiarizing myself with the project etc, so I don't want to raise any expectations still, but thought I'd let you know 🙂

antonagestam avatar Dec 01 '22 19:12 antonagestam

That's great news, let me know if you have any questions. Good luck.

samuelcolvin avatar Dec 01 '22 19:12 samuelcolvin