Skip to content

add a timestamp() method to datetime.date class #103072

@ZeeD

Description

@ZeeD

Feature or enhancement

Extend the datetime.date class with a new method timestamp() that mimic the same behavior of datetime.datetime.timestamp, where the time is implicitly "00:00".

Pitch

At the moment both datetime.datetime and datetime.date offers the fromtimestamp() classmethod to convert from float.
datetime.datetime objects, moreover, offer the timestamp() method to convert to float.
A similar method lacks for datetime.date.

Apart from the (lack of) symmetry, there are also some use cases where it's necessary to switch back-and-forth between datetime.dates and floats and it would be handy to have some predefined function already.

Previous discussion

https://discuss.python.org/t/a-timestamp-method-for-date-objects/13340

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions