pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

Add utc variant now for factory use

Open whardier opened this issue 5 years ago • 2 comments

Using pendulum in pydantic has me writing code similar to Field(default_factory=lambda: now('UTC')) to ensure UTC regardless of system timezone settings. It would be nice to have a utcnow() variant that will allow for writing code similar to Field(default_factory=utcnow) ready and available with new versions of pendulum.

whardier avatar Jul 21 '20 04:07 whardier

We really do need pendulum.utcnow() to handle a common use case and simplify how we approach things with Pydantic schemas and the like.

whardier avatar Nov 30 '20 06:11 whardier

Nevermind.. looks like this exists as pendulum.datetime.DateTime.utcnow (after importing just DateTime)

whardier avatar Nov 30 '20 06:11 whardier