On Wed, Jul 3, 2013 at 9:08 PM, K. Frank <[email protected]> wrote:
> Hello List!
>
> strftime does not seem to parse the "%T" format specifier.
>
> First of all, I don't actually know what is supposed to happen.  However,
> this reference:
>
>    http://www.cplusplus.com/reference/ctime/strftime/
>
> states that "%T" is supposed to be a synonym for "%H:%M:%S":
>
>    %T   ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S   14:55:02
>
> Anyway, when I use "%T" in my format string, strftime returns 0 as the
> number of characters copied to the output buffer.
>
> This is nothing urgent for me -- I can simply use "%H:%M:%S".  I only
> bring this up because g++ seems not to agree with some random bit of
> documentation I found on the internet.
>
> Here's the output from a sample program:
>
>    C:\>strftime_test.exe
>    cnt1 = 17, buf1 = 20130702-13:14:15
>    cnt2 = 0, buf2 =
>
> the compile line:
>
>    C:\>g++ -o strftime_test strftime_test.cpp
>
> the compiler version:
>
>    C:\>g++ --version
>    g++ (rubenvb-4.8-stdthread) 4.8.1 20130324 (prerelease)
>
> and the test program:
>
> === strftime_test.cpp ===
>
>    #include <ctime>
>    #include <iostream>
>    int main (int argc, char *argv[]) {
>      tm mytm = { 15, 14, 13, 2, 6, 113 };  // not portable
>
>      char buf1[129];
>      int cnt1 = strftime (buf1, 128, "%Y%m%d-%H:%M:%S", &mytm);
>      std::cout << "cnt1 = " << cnt1 << ", buf1 = " << buf1 << std::endl;
>
>      char buf2[129];
>      int cnt2 = strftime (buf2, 128, "%Y%m%d-%T", &mytm);
>      std::cout << "cnt2 = " << cnt2 << ", buf2 = " << buf2 << std::endl;
>    }
>
> ===          ===
>
>
> Thanks for any feedback.
>
>
> K. Frank

strftime() is imported from msvcrt.dll, therefore it behaves the way MS
authored it.

--
O.S.

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to