Conversation
| @property | ||
| def description(self): | ||
| return f"{self.name} at {self.end_time.strftime('%-I:%M %p')}" | ||
| return f"{self.name} at {self.end_time.strftime('%-H:%M %p')}" |
There was a problem hiding this comment.
@brunetton does this break the AM/PM format?
Some people may be using it, I assume
There was a problem hiding this comment.
It's a good question and I searched a while to figure out. At the beginning I thought that using %H with %p would check in locale def for the locale preferences and use 12h or 24h according to it. But the doc isn't clear on this point.
I digged around and I'm not sure anymore: is the 12h format automatic when locale is en_US ? Apparently this is a free interpretation. It made quite a mess in Debian when they changed it (I didn't read the whole thread).
I didn't found any "official" reference on this and this comment seems to go in flavor of local preferences.
I tried using specialized libs like Pendulum and Arrow but they seems to follow the same formatting as standard DateTime: 24h format by default.
So I guess this is a matter of local choice and I suggest that we add an option to the user to use 12h format or not.
What do you think about ?
|
One, although a bit hacky, way would be to put an if-else there. In the if
statement detect when a user wants to use 24h format, in the else - keep
the am/pm format.
The detection could be implement using either regex or by datetime parsing.
I haven't thoroughly thought about all nuances, but it should work, right?
…On Mon, Mar 27, 2023, 16:55 Bruno Duyé ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In timer/Timer.py
<#23 (comment)>
:
> self.tag = None
@Property
def description(self):
- return f"{self.name} at {self.end_time.strftime('%-I:%M %p')}"
+ return f"{self.name} at {self.end_time.strftime('%-H:%M %p')}"
It's a good question and I searched a while to figure out. At the
beginning I thought that using %H with %p would check in locale def for
the locale preferences and use 12h or 24h according to it. But the doc
<https://docs.python.org/fr/3.6/library/datetime.html#strftime-strptime-behavior>
isn't clear on this point.
I digged around and I'm not sure anymore: is the 12h format automatic when
locale is en_US ? Apparently this is a free interpretation. It made quite a
mess in Debian when they changed it
***@***.***/msg1662042.html>
(I didn't read the whole thread).
I didn't found any "official" reference on this and this comment
<https://serverfault.com/a/1094385/506648> seems to go in flavor of local
preferences.
I tried using specialized libs like Pendulum
<https://pendulum.eustace.io/docs> and Arrow
<https://arrow.readthedocs.io/en/latest> but they seems to follow the
same formatting as standard DateTime: 24h format by default.
So I guess this is a matter of local choice and I suggest that we add an
option to the user to use 12h format or not.
What do you think about ?
—
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJFS3272GKHHF6PH5MC2OLW6GL3ZANCNFSM6AAAAAAWHORPWI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
To be sure to understand: if the user type something like
IMHO a global option for 12h format is simple to understand for users and super keep a code simple to maintain. I can do this :) |
|
@brunetton I took a closer look at the code. I realized I may have misunderstood your intentions. I'll be happy to review PRs whether it's the first case or second or both. |
Indeed :) Happy to see that we agree on that
Yes I already read all the code I think and indeed to parse it's a little more complicated. We would really need to use a third party lib as Moment or something similar. But this is not my need for the moment as I only use timers in minutes from now
Great ! |
Fix #20