Closed zzstoatzz closed 5 days ago
%l gives 12-hour format with a leading space if H < 10 but doesnt work on windows and some linux
%l
%I is the closest platform independent analog but requires some wrangling to give the desired format
%I
closes concern raised in this comment and see similar issue here
In [1]: import datetime In [2]: def format_timestamp(timestamp: datetime.datetime) -> str: ...: local_timestamp = timestamp.astimezone() ...: return local_timestamp.strftime("%I:%M:%S %p").lstrip("0").rjust(11) ...: In [3]: format_timestamp(datetime.datetime.fromtimestamp(123456)) Out[3]: ' 4:17:36 AM'
Thanks @zzstoatzz!
I've made this change locally and it resolves the issue. Any chance of a new patch release soon?
%l
gives 12-hour format with a leading space if H < 10 but doesnt work on windows and some linux%I
is the closest platform independent analog but requires some wrangling to give the desired formatcloses concern raised in this comment and see similar issue here
behavior after this PR