line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package XML::SRS::Date; |
3
|
|
|
|
|
|
|
BEGIN { |
4
|
1
|
|
|
1
|
|
4498
|
$XML::SRS::Date::VERSION = '0.09'; |
5
|
|
|
|
|
|
|
} |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
589
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use PRANG::Graph; |
9
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
10
|
|
|
|
|
|
|
use MooseX::Params::Validate; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
BEGIN { |
13
|
|
|
|
|
|
|
subtype "XML::SRS::Date::ymd" |
14
|
|
|
|
|
|
|
=> as "Str" |
15
|
|
|
|
|
|
|
=> where { |
16
|
|
|
|
|
|
|
m{^(\d{4})-(\d{1,2})-(\d{1,2})$}; |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
subtype 'XML::SRS::Date::Year' |
20
|
|
|
|
|
|
|
=> as "Int", |
21
|
|
|
|
|
|
|
=> where { |
22
|
|
|
|
|
|
|
length(0+$_) == 4; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
subtype 'XML::SRS::Date::Month' |
25
|
|
|
|
|
|
|
=> as "Int", |
26
|
|
|
|
|
|
|
=> where { |
27
|
|
|
|
|
|
|
$_ >= 1 and $_ <= 12; |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
subtype 'XML::SRS::Date::Day' |
30
|
|
|
|
|
|
|
=> as "Str", |
31
|
|
|
|
|
|
|
=> where { |
32
|
|
|
|
|
|
|
$_ >= 1 and $_ <= 31; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has_attr 'year' => |
37
|
|
|
|
|
|
|
is => "rw", |
38
|
|
|
|
|
|
|
isa => "XML::SRS::Number", |
39
|
|
|
|
|
|
|
required => 1, |
40
|
|
|
|
|
|
|
xml_name => "Year", |
41
|
|
|
|
|
|
|
; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has_attr 'month' => |
44
|
|
|
|
|
|
|
is => "rw", |
45
|
|
|
|
|
|
|
isa => "XML::SRS::Number", |
46
|
|
|
|
|
|
|
required => 1, |
47
|
|
|
|
|
|
|
xml_name => "Month", |
48
|
|
|
|
|
|
|
; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has_attr 'day' => |
51
|
|
|
|
|
|
|
is => "rw", |
52
|
|
|
|
|
|
|
isa => "XML::SRS::Number", |
53
|
|
|
|
|
|
|
required => 1, |
54
|
|
|
|
|
|
|
xml_name => "Day", |
55
|
|
|
|
|
|
|
; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub buildargs_date { |
58
|
|
|
|
|
|
|
my $inv = shift; |
59
|
|
|
|
|
|
|
my ( $ymd ) = pos_validated_list( |
60
|
|
|
|
|
|
|
\@_, |
61
|
|
|
|
|
|
|
{ isa => 'XML::SRS::Date::ymd' }, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @buildargs; |
65
|
|
|
|
|
|
|
my ($y, $m, $d) = split "-", $ymd; |
66
|
|
|
|
|
|
|
push @buildargs, year => $y, month => $m, day => $d; |
67
|
|
|
|
|
|
|
@buildargs; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub date { |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return sprintf( |
74
|
|
|
|
|
|
|
"%.4d-%.2d-%.2d", |
75
|
|
|
|
|
|
|
$self->year, $self->month, $self->day, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |