I'm the author of the Mac::PropertyList module which parses the Apple property list format. I've designed this to work across platforms, but I'm having trouble with POSIX's strftime
function which I use to create the 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 produces the right sort of date:
2013-09-23T12:34:56Z
On Windows, it produces:
T12:34:56Z
This was reported as CPAN RT #83460. What's going on with Windows here?
The POSIX module permits you to access all (or nearly all) the standard POSIX 1003.1 identifiers. Many of these identifiers have been given Perl-ish interfaces. This document gives a condensed list of the features available in the POSIX module.
Perl POSIX Function strftime() The Perl POSIX strftime() function is used to format date and time with the specifiers preceded with (%) sign. There are two types of specifiers, one is for local time and other is for gmt time zone.
As I was writing this question and researching everything, I found my own answer. I don't want all that work to go to waste though.
The %F
format I used is not portable, and the POSIX module says so 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
is really %Y-%m-%d
, so I should use that.
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 the strftime
man page to see what they do. In looking at the man page, I forget to check which ones are portable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With