aboutsummaryrefslogtreecommitdiff
path: root/challenge-326/e-choroba/perl/ch-1.pl
blob: 26b78b42aa20d992d0a30a8d893b5d4b4a1c38d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl
use warnings;
use strict;
use experimental qw( signatures );

use Time::Piece;

sub day_of_the_year($date) {
    my $tp = 'Time::Piece'->strptime($date, '%Y-%m-%d');
    return 1 + $tp->yday
}

use Test::More tests => 3 + 1;

is day_of_the_year('2025-02-02'), 33, 'Example 1';
is day_of_the_year('2025-04-10'), 100, 'Example 2';
is day_of_the_year('2025-09-07'), 250, 'Example 3';

is day_of_the_year('2024-09-07'), 251, 'Leap year';