Help language development. Donate to The Perl Foundation
# # Checking the attributes of dates built with year, month, day values # use Test; use Date::Calendar::Persian; use Date::Calendar::Persian::Astronomical; my @tests = (('zzz', 3, 'zzz') , ('%Y-%m-%d', 10, '1399-11-28') , ('%j', 3, '334') , ('%Oj', 3, '334') , ('%Ej', 3, '334') , ('%Ey', 3, '%Ey') , ('%a', 3, '3sh') , ('%A', 9, 'Se shanbe') , ('%u', 1, '4') , ('%B', 6, 'Bahman') , ('%b', 3, 'Bah') , ('%Y', 4, '1399') , ('%G', 4, '1399') , ('%V', 2, '48') ); plan 8 + 2 × @tests.elems + 5 + 5; my Date::Calendar::Persian $d .= new(year => 1399, month => 11, day => 28); is($d.month, 11); is($d.day, 28); is($d.year, 1399); is($d.daycount, 59261); is($d.day-of-week, 4); is($d.day-of-year, 334); is($d.week-year, 1399); is($d.week-number, 48); for @tests -> $test { my ($format, $length, $expected) = $test; my Str $result = $d.strftime($format); # Remembering RT ticket 100311 for the Perl 5 module DateTime::Calendar::FrenchRevolutionary # see https://github.com/jforget/DateTime-Calendar-FrenchRevolutionary/issues/6 # Even if the relations between UTF-8 and Perl6 are much simpler than between UTF-8 and Perl5 # better safe than sorry is($result.chars, $length); is($result, $expected); } # 2025-03-21 (Gregorian) translates as 1404-01-01 with the astronomical calendar # and as 1404-01-02 with the arithmetic calendar # see Calendrical Calculations 3rd publishing page 225 $d .= new(year => 1404, month => 1, day => 2); is($d.daycount, 60755); is($d.day-of-year, 2); is($d.day-of-week, 7); is($d.week-year, 1403); is($d.week-number, 52); my Date::Calendar::Persian::Astronomical $d1; $d1 .= new(year => 1404, month => 1, day => 1); is($d1.daycount, 60755); is($d1.day-of-year, 1); is($d1.day-of-week, 7); is($d1.week-year, 1403); is($d1.week-number, 52); done-testing;