On Wed, Jan 29, 2003 at 11:39:00AM -0600, Dave Rolsky wrote: > On Wed, 29 Jan 2003, Tim Bunce wrote: > > > 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. > > [autarch@penguin ~]$ perl -le 'print sprintf("%02d", 1970)' > 1970 > [autarch@penguin ~]$ perl -le 'print sprintf("%02d", 1)' > 01 > > Maybe it should be %04d though.
Yeap. As you're specifically supporting years < 1000, I believe. Tim.