[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [MacPerl] Munging dates



Its not as nice as Chris' solution but does this help :-

require "ctime.pl";
%MoY = ('Jan' => '01',
        'Feb' => '02',
        'Mar' => '03',
        'Apr' => '04',
        'May' => '05',
        'Jun' => '06',
        'Jul' => '07',
        'Aug' => '08',
        'Sep' => '09',
        'Oct' => '10',
        'Nov' => '11',
        'Dec' => '12'
        );
$current = &ctime(time);
($wday,$mon,$mday,$time,$year) = split(/\s+/,$current);
$mday = sprintf("%-2.2i",$mday);
$today = "$mday/$MoY{$mon}/$year";
$ymd   = join("",substr($year,2,2),"$MoY{$mon}$mday");

REGARDS
Poorly
'I write crap code like this all the time.'
_______________________________________________________________________________
From: jw35@cus.cam.ac.uk on Tue, 13 Jan 1998 5:43 AM
Subject: [MacPerl] Munging dates
To: MacPerl

I spent part of the weekend trying to identify a suitable routine to
use under MacPerl to parse human-readable dates and turn them into
something that Perl can process. From CPAN I found what looks like
three candindtes:

  Date::Parse from a group of routines by Graham Barr. Appears to 
  work OK, but can only handle American style dates (1/2/1998 is 
  2nd January rather than 1st February) which is a problem for me.

  Time::ParseDate from a group of routines by Muir Sharnoff. Handles
  UK dates, but returns seconds since 1 Jan 1970, rather than from
  the normal Mac origin of 1 Jan 1907. I thought I could see how
  to fix this, but the routines use integer arrithmatic and the 'fix'
  seems to cause integer limits to be broken inside the code.

  Date::Manip by Sullivan Beck. I haven't looked at this in detail, 
  but it seems to be more complex than I need, and has the added
  drawback of returning a text string date rather than seconds
  since epoc.

Given this state of affairs, has anyone any suggestions as to how to 
procede or of better routines to try?

Jon.
--
Jon Warbrick, Computer Systems Manager,                jw35@cus.cam.ac.uk
St John's College, Cambridge, CB2 1TP, UK.             +44 (0)1223 338751
(also webmaster, computer-support and part-time postmaster@joh.cam.ac.uk)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch