line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
### Change History |
2
|
|
|
|
|
|
|
# 1999-12-05 Added simplistic two_digit_window. |
3
|
|
|
|
|
|
|
# 1999-08-13 Added zero_padded |
4
|
|
|
|
|
|
|
# 1998-12-02 Created. -Simon |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Data::Quantity::Time::Year; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require 5; |
9
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
10
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
65
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
13
|
|
|
|
|
|
|
$VERSION = 0.001; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use Data::Quantity::Number::Integer '-isasubclass'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# undef = Data::Quantity::Time::Year->scale(); |
18
|
|
|
|
|
|
|
sub scale { |
19
|
0
|
|
|
0
|
0
|
0
|
return 'Year'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# $value = Data::Quantity::Time::Year->readable_value($number) |
23
|
|
|
|
|
|
|
# $value = Data::Quantity::Time::Year->readable_value($number, $style) |
24
|
|
|
|
|
|
|
sub readable_value { |
25
|
7
|
|
|
7
|
0
|
8
|
my $class_or_item = shift; |
26
|
7
|
|
|
|
|
7
|
my $value = shift; |
27
|
|
|
|
|
|
|
|
28
|
7
|
|
|
|
|
60
|
return $value; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# $padded = $quantity->zero_padded(); |
32
|
|
|
|
|
|
|
sub zero_padded { |
33
|
0
|
|
|
0
|
0
|
|
my $year_q = shift; |
34
|
0
|
0
|
|
|
|
|
$year_q->SUPER::zero_padded( scalar @_ ? @_ : 4 ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub two_digit_window { |
38
|
0
|
|
|
0
|
0
|
|
my $year_q = shift; |
39
|
0
|
|
|
|
|
|
my $years = $year_q->value; |
40
|
|
|
|
|
|
|
|
41
|
0
|
0
|
0
|
|
|
|
if ( $years > 1939 and $years < 2040 ) { |
42
|
0
|
|
|
|
|
|
$years =~ s/\A\d\d//; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return $years; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# $flag = $quantity->is_leap_year; |
48
|
|
|
|
|
|
|
sub is_leap_year { |
49
|
0
|
|
|
0
|
0
|
|
my $year_q = shift; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
require Time::DaysInMonth; |
52
|
0
|
|
|
|
|
|
return Time::DaysInMonth::is_leap( $year_q->value ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |