On the 25th of September I wrote: >I have several Perl scripts written for a unix platform that makes calls >to 'date' using various +format options. Does anyone have a module or code >fragment suitable for use in MacPerl that could handle this call with >suitable changes to the original code (rather than a complete rewrite >using time(), etc.)? A number of you responded with ideas (*THANKS*), which mostly suggested various CPAN modules. However, one suggestion was to use the POSIX strftime() function that comes with the MacPERL distribution. This I did, along the lines of: #!perl use POSIX; $s = strftime("%A, %B %d, %Y",localtime(time())) ."\n"; print $s; .... this simple example yielded the following earlier today: Tuesday, September 30, 1997 Although this is probably "old hat" to most of you, I went futher by exploring what format options were supported by this module under MacPERL. Perhaps this will be of use to some of you. Those formatting options that worked for me follow below! >From the Perl5 manpage on the POSIX module: strftime Convert date and time information to string. Returns the string. Synopsis: strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0) The month (mon), weekday (wday), and yearday (yday) begin at zero. I.e. January is 0, not 1; Sunday is 0, not 1; January 1st is 0, not 1. The year (year) is given in years since 1900. I.e. The year 1995 is 95; the year 2001 is 101. Consult your system's strftime() manpage for details about these and the other arguments. The string for Tuesday, December 12, 1995. $str = POSIX::strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 ); print "$str\n"; Since there is no manpage for strftime() on a Mac, I looked at the one on my SGI machine. After trying all of the listed field descriptors, these are the ones that worked running MacPerl: Field Descriptors (must be preceded by a %): a locale's abbreviated weekday name A locale's full weekday name b locale's abbreviated month name B locale's full month name c locale's appropriate date and time representation d day of month as a decimal number [01-31] H hour (24-hour clock) as a decimal number [00-23] I hour (12-hour clock) as a decimal number [01-12] j day of year as a decimal number [001-366] m month of year as a decimal number [01-12] M minute as a decimal number [00-59] p string containing ante-meridian or post-meridian indicator (by default, AM or PM) S seconds as a decimal number [00-61], allows for leap seconds U week number of year (Sunday as the first day of the week) as a decimal number [00-53]. All days in a new year preceding the first Sunday are considered to be in week 0. w weekday as a decimal number [0(Sunday)-6] W week of year (Monday as the first day of the week) as a decimal number [00-53]. All days in a new year preceding the first Sunday are considered to be in week 0. x locale's appropriate date representation X locale's appropriate time representation y year within century (offset from %C) as a decimal number [00-99] Y year as _c_c_y_y (4 digits) % insert a percent sign character :-) Dave Beck dfbeck@sandia.gov ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch