-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hyphenated formats for non-zero padded numbers #13
Comments
Implementing this is probably trivial, but if you could provide us with test cases in Go test format, that would be a great start. |
as a personal reminder: from the glibc doc
This is an extension, so the implementation would fall into the extensions mechanism like |
@lestrrat use case here... Getting the front page of the new york times: we want numbers below 10 to simply return without padding: eg: https://cdn.newseum.org/dfp/pdf1/NY_NYT.pdf certainly seems to be supported by other implementations |
@lestrrat I generated some test cases with this snippet #include <stdio.h>
#include <time.h>
int main() {
struct tm {
1, /* seconds, range 0 to 59 */
1, /* minutes, range 0 to 59 */
1, /* hours, range 0 to 23 */
1, /* day of the month, range 1 to 31 */
1, /* month, range 0 to 11 */
-1000, /* The number of years since 1900 */
1, /* day of the week, range 0 to 6 */
1, /* day in the year, range 0 to 365 */
0, /* daylight saving time */
};
char buffer[200];
strftime(buffer, 200, "%d|%e|%H|%I|%j|%k|%l|%M|%m|%S|%U|%V|%W|%y|%z", &t);
printf(buffer);
printf("\n");
strftime(buffer, 200, "%-d|%-e|%-H|%-I|%-j|%-k|%-l|%-M|%-m|%-S|%-U|%-V|%-W|%-y|%-z", &t);
printf(buffer);
printf("\n");
} Which gives the output
The format codes excluded from the snippet don't change when including a hyphen. |
Some strftime implementations support non-zero padded numbers.
For example, in Python
This is documented in glibc's strftime.
Windows has its own set of codes which use
#
instead of-
:https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?redirectedfrom=MSDN&view=vs-2019
Another reference: https://strftime.org/#platforms
The text was updated successfully, but these errors were encountered: