[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution

2020-04-18 Thread Or Toledano
New submission from Or Toledano : I propose the zero(time_unit) function, which replaces all time units with greater equal resolution than time_unit by 0. E.g. >>> datetime.datetime(2020, 4, 18, 12, 27, 30, 500).zero("second") datetime.datetime(2020, 4, 18, 12, 27) I

[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution

2020-04-18 Thread Or Toledano
Change by Or Toledano : -- keywords: +patch pull_requests: +18918 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19580 ___ Python tracker <https://bugs.python.org/issu

[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution

2020-04-18 Thread Or Toledano
Or Toledano added the comment: https://github.com/python/cpython/pull/19580 -- ___ Python tracker <https://bugs.python.org/issue40316> ___ ___ Python-bugs-list m

[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution

2020-04-18 Thread Or Toledano
Or Toledano added the comment: The use-case for this method is to "limit" the resolution of a time object. I encountered the need for it when I needed to reduce the resolution of some timestamps, to compare them with timestamps of lesser resolution. I found the following SOF po