On Tue, Jan 28, 2003 at 05:05:07PM -0600, Dave Rolsky wrote:
> On Tue, 28 Jan 2003, Tim Bunce wrote:
> 
> > On Tue, Jan 28, 2003 at 11:07:51AM -0600, Dave Rolsky wrote:
> > > On Tue, 28 Jan 2003, Tim Bunce wrote:
> > >
> > > > The ymd, mdy, and dmy methods all use two digit years. That's not
> > > > ideal but I can understand people might like it. I'd strongly suggest
> > > > that they be renamed yymmdd, mmddyy, ddmmyy, and the corresponding
> > > > four digit year methods added as: yyyymmdd, mmddyyyy, ddmmyyyy.
> > > > (Similary hms could be renamed hhmmss for consistency.)
> > >
> > > Um, no they don't.
> >
> > Eh?
> 
> They return 4 digit years.  In fact, the only way to get a 2-digit year
> right now is is $dt->strftime('%y').

The code shown by the URL you posted generates two digit years:

sub ymd {
    my ( $self, $sep ) = @_;
    $sep = '-' unless defined $sep;
    return sprintf( "%02d$sep%02d$sep%02d", $self->_as_greg );
}
*date = \&ymd;

sub mdy {
    my ( $self, $sep ) = @_;
    $sep = '-' unless defined $sep;
    return sprintf( "%02d$sep%02d$sep%02d", ($self->_as_greg)[1,2,0] );
}

sub dmy {
    my ( $self, $sep ) = @_;
    $sep = '-' unless defined $sep;
    return sprintf( "%02d$sep%02d$sep%02d", reverse $self->_as_greg );
}

Maybe there's a later version.

Tim.

Reply via email to