On 2 Sep 2004, at 2:51 PM, Rick Measham wrote:
It'd be really ugly to do stuff like:
  $dt = $strptime->parse_datetime( $string, asa => 'My::DateTime' );

But we could do something similar with just a change in DateTime itself. We have a 'from_object' constructor -- How about adding an 'asa' method. (I call it asa because it's like isa)


$my_datetime = $strptime->parse_datetime($string)->asa('My::DateTime');

Then in DateTime.pm:

  sub asa {
    my ($self, $class) = @_;

    eval { require $class };
    die($@) if $@;

eval { my $newself = $class->from_object( $self ) }
die("$class is unable to accept a DateTime: $@") if $@ or not defined $newself;


    return $newself;
  }


Senior Developer PrintSupply - Print Procurement & Supply Management 18 Greenaway Street VIC 3105 Tel: (03) 9850 3255 Fx: (03) 9850 3277 http://www.printsupply.com.au/




Reply via email to