PrefectHQ / ControlFlow

🦾 Take control of your AI agents
https://controlflow.ai
Apache License 2.0
337 stars 15 forks source link

platform independent timestamp #193

Closed zzstoatzz closed 5 days ago

zzstoatzz commented 5 days ago

%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 format

closes concern raised in this comment and see similar issue here

behavior after this PR

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'
image
jlowin commented 5 days ago

Thanks @zzstoatzz!

lieutdan13 commented 7 hours ago

I've made this change locally and it resolves the issue. Any chance of a new patch release soon?