my
$input_date
=
'2020.'
;
my
$ret
= clean_date(
$input_date
);
is(
$ret
, 2020,
"Date '$input_date' after cleanup."
);
$input_date
= decode_utf8(
'2020 př. Kr.'
);
$ret
= clean_date(
$input_date
);
is(
$ret
, -2020, encode_utf8(
"Date '$input_date' after cleanup."
));
$input_date
= decode_utf8(
'20 po. Kr.'
);
$ret
= clean_date(
$input_date
);
is(
$ret
, 20, encode_utf8(
"Date '$input_date' after cleanup."
));
$input_date
= decode_utf8(
'2020 březen 03.'
);
$ret
= clean_date(
$input_date
);
is(
$ret
,
'2020-03-03'
, encode_utf8(
"Date '$input_date' after cleanup."
));
$input_date
= decode_utf8(
'2020 leden 3.'
);
$ret
= clean_date(
$input_date
);
is(
$ret
,
'2020-01-3'
, encode_utf8(
"Date '$input_date' after cleanup."
));
$input_date
=
undef
;
$ret
= clean_date(
$input_date
);
is(
$ret
,
undef
, encode_utf8(
"Undefined date after cleanup."
));
$input_date
=
'c2002'
;
(
$ret
,
my
$options_hr
) = clean_date(
$input_date
);
is(
$ret
, 2002, encode_utf8(
"Date '$input_date' after cleanup."
));
is_deeply(
$options_hr
,
{
'circa'
=> 1,
},
"Date '$input_date' has option 'circa'."
);
$input_date
=
'asi 2002'
;
(
$ret
,
$options_hr
) = clean_date(
$input_date
);
is(
$ret
, 2002, encode_utf8(
"Date '$input_date' after cleanup."
));
is_deeply(
$options_hr
,
{
'circa'
=> 1,
},
"Date '$input_date' has option 'circa'."
);
$input_date
= decode_utf8(
'asi 2510 př. Kr.'
);
(
$ret
,
$options_hr
) = clean_date(
$input_date
);
is(
$ret
, -2510, encode_utf8(
"Date '$input_date' after cleanup."
));
is_deeply(
$options_hr
,
{
'circa'
=> 1,
},
encode_utf8(
"Date '$input_date' has option 'circa'."
)
);