Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Date/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ format, which returns in the form "2006-04-12".
=cut

sub ymd {
sprintf( "%04u-%02u-%02u",
sprintf( "%04.4d-%02u-%02u",
$_[0]->year,
$_[0]->month,
$_[0]->day,
Expand Down
20 changes: 19 additions & 1 deletion t/02_main.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ BEGIN {
$^W = 1;
}

use Test::More tests => 19;
use Test::More tests => 21;
use Date::Tiny;


Expand Down Expand Up @@ -80,3 +80,21 @@ SCOPE: {
is( $date->month, 1, '->month ok' );
is( $date->day, 31, '->day ok' );
}

# Testing stringification

SCOPE: {
my $date = Date::Tiny->new(
year => 6,
month => 1,
day => 31
);
is( "$date", '0006-01-31', 'stringification positive year ok' );

$date = Date::Tiny->new(
year => -3,
month => 7,
day => 5
);
is( "$date", '-0003-07-05', 'stringification negative year ok' );
}