msg157048 - (view) |
Author: Walter Cheuk (wwycheuk) |
Date: 2012-03-29 14:05 |
Please add new directives for decimal-number month, day and hour that have neither leading zero nor leading space. Currently %m, %d and %I are used, but they have leading zeroes and are not suitable for some languages such as Chinese. GNOME provides %e and %l for day and hour, but they have leading space instead and are not good enough also. |
|
|
msg157049 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-03-29 14:14 |
We pretty much follow the posix standard on strftime. I doubt that we would introduce non-standard specifiers. Are there any in widespread use for your use case? |
|
|
msg157050 - (view) |
Author: Walter Cheuk (wwycheuk) |
Date: 2012-03-29 14:32 |
Yes, this is standard in all Chinese locales, including China, Taiwan, Hong Kong, Macau and Singapore. |
|
|
msg157051 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-03-29 14:43 |
I'm asking if there are specific % codes commonly used for this case. (Even if there are there is no guarantee we are going to add them, but it makes it possible to make a case for it.) |
|
|
msg157056 - (view) |
Author: Walter Cheuk (wwycheuk) |
Date: 2012-03-29 15:10 |
Usually %m, %d and %I are used instead, but the result is not satisfactory. |
|
|
msg157058 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-03-29 15:23 |
It turns out that there is standard way to do this (well, a de-facto standard, anyway). glibc (and apparently others) support 'modifiers', of which the '-' modifier will suppress 0 padding. Furthermore, since we pass the format string through to glibc, Python *already* supports this on glibc based platforms, though it isn't documented: >>> t.strftime("%m") '03' >>> t.strftime("%-m") '3' |
|
|
msg157084 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2012-03-29 18:48 |
Can we change this to a documentation bug? I was unaware of the use of '-', and I think most other people are, too. Although having just checked, it doesn't work under Windows :(. So maybe we shouldn't document it. Thinking out loud: I've often thought we should write our own strptime/strftime. I think cross-platform consistency here would be a win. |
|
|
msg157085 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2012-03-29 19:08 |
I think there may even be an issue for that, but with the currently broken issue search I'm not sure. Issue 3173 *might* be what I'm thinking of (thanks, google). And yes, the fact that stuff like this is not cross-platform is why it isn't documented, and why I said "on glibc based platforms" :) (I think there is a doc note about additional directives possibly being defined by the platform.) |
|
|
msg157086 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2012-03-29 19:11 |
Heh. You're correct about 3173. And I'm even nosy on that issue! |
|
|