Why does the Perl POSIX :: strftime% F specifier not work on Windows?

I am the author of the Mac :: PropertyList module, which parses the Apple property list format. I designed this to work on different platforms, but I'm having problems with the POSIX strftime function, which I use to create date fields in the format that Apple specifies.

 use POSIX; print 'Epoch is: ' . POSIX::strftime( "%FT%H:%M:%SZ\n", gmtime(978307200) ); 

On unix-like platforms, including darwin, this call creates the correct date type:

 2013-09-23T12:34:56Z 

On Windows, this produces:

 T12:34:56Z 

This has been reported as CPAN RT # 83460 . What is happening with windows here?

+9
windows posix perl
source share
1 answer

Since I wrote this question and studied everything, I found my own answer. I do not want all of this work to disappear, though.

The %F format I used is not portable, and the POSIX module says in its strftime entry:

 If you want your code to be portable, your format ("fmt") argument should use only the conversion specifiers defined by the ANSI C standard (C89, to play safe). These are "aAbBcdHIjmMpSUwWxXyYZ%". 

%F really %Y-%m-%d , so I have to use this.

My particular problem is that I know that the POSIX module tells you which format specifiers you can use to be portable, but I still have to look at strftime to see what they do. When I look at the manual page, I forget to check which ones are portable.

+14
source share

All Articles