File: iso_date_example.t

package info (click to toggle)
libmethod-signatures-perl 20170211-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 676 kB
  • sloc: perl: 3,860; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 370 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl -lw

package Date;

use Method::Signatures;

method new($class:@_) {
    bless {@_}, $class;
}

method iso_date(
    :$year!,    :$month = 1, :$day = 1,
    :$hour = 0, :$min   = 0, :$sec = 0
)
{
    return sprintf "%04d-%02d-%02d %02d:%02d:%02d", $year, $month, $day, $hour, $min, $sec;
}

my $date = Date->new();
print $date->iso_date( year => 2008 );