Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
25.76k stars 795 forks source link

Travel back in time to 1900 #4666

Open lawrenceakka opened 5 months ago

lawrenceakka commented 5 months ago

This is not really a bug - more of a small feature request.

The HeaderClock is, well, a clock. It displays the time. It would be nice if it could display the date as well. I spent more time than I will admit trying to figure out why, when I set time_format on Header() to "%c" the time is displayed as 'Mon Jan 1 22:36:22 1900'. In fact, it is because line 92 in header.py says:

return Text(datetime.now().time().strftime(self.time_format))

When a datetime is converted by time(), all date info is stripped.

The time() seems unnecessary. I propose that the line be replaced by

return Text(datetime.now().strftime(self.time_format))

That would allow date formatting strings to be used as well, for those of us who can't remember what day it is. You might also need to change the default width on HeaderClockSpace to auto.

I'll do a PR if you really want one :)

github-actions[bot] commented 5 months ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

willmcgugan commented 5 months ago

Happy to accept a PR for that.