Skip to content

Use of datetime.utcfromtimestamp() on 3.12+ is also deprecated #384

Closed
@slothkong

Description

@slothkong

Hello there,

Although as of 1.7.0, deprecation of datetime.utcnow() was delt with by @RazerM ( 5273fa2 ), it seems like datetime.utcfromtimestamp() also requires some attention.

The official datetime docs point out:

Warning: Because naive datetime objects are treated by many datetime methods as local times, it is preferred to use aware datetimes to represent times in UTC. As such, the recommended way to create an object representing a specific timestamp in UTC is by calling datetime.fromtimestamp(timestamp, tz=timezone.utc).

For context, stumbled upon the deprecation warning while unittesting dbt-core, as part of issue 9791. When drilling down the logs, ended up at:

return datetime.utcfromtimestamp(timestamp)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions