Days between dates: Difference between revisions
Content added Content deleted
(→{{header|zkl}}: added code) |
SqrtNegInf (talk | contribs) (Added Perl example) |
||
Line 106: | Line 106: | ||
There are 274 days between 2015-12-31 and 2016-09-30 |
There are 274 days between 2015-12-31 and 2016-09-30 |
||
</pre> |
</pre> |
||
=={{header|Perl}}== |
|||
Would not reinvent this wheel. |
|||
<lang perl>use feature 'say'; |
|||
use Date::Calc qw(Delta_Days); |
|||
say Delta_Days(2018,7,13, 2019,9,13); # triskaidekaphobia |
|||
say Delta_Days(1900,1,1, 2000,1,1); # a century |
|||
say Delta_Days(2000,1,1, 2100,1,1); # another, with one extra leap day |
|||
say Delta_Days(2020,1,1, 2019,10,1); # backwards in time |
|||
say Delta_Days(2019,2,29, 2019,3,1); # croaks</lang> |
|||
{{out}} |
|||
<pre>427 |
|||
36524 |
|||
36525 |
|||
-92 |
|||
Date::Calc::PP::Delta_Days(): Date::Calc::Delta_Days(): not a valid date at Days_between_dates line 10</pre> |
|||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |