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
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.datetimeanddatetime.dateoffers thefromtimestamp()classmethod to convert fromfloat.datetime.datetimeobjects, moreover, offer thetimestamp()method to convert tofloat.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 andfloats 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
timestamp()method todatetime.date#131226