Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   strftime    ( 3 )

формат даты и времени (format date and time)

Ошибки (баги) (Bugs)

If the output string would exceed max bytes, errno is not set.
       This makes it impossible to distinguish this error case from
       cases where the format string legitimately produces a zero-length
       output string.  POSIX.1-2001 does not specify any errno settings
       for strftime().

Some buggy versions of gcc(1) complain about the use of %c: warning: `%c' yields only last 2 digits of year in some locales. Of course programmers are encouraged to use %c, as it gives the preferred date and time representation. One meets all kinds of strange obfuscations to circumvent this gcc(1) problem. A relatively clean one is to add an intermediate function

size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { return strftime(s, max, fmt, tm); }

Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the warning, so that the above workaround is no longer required.