lib/OWL/Data/DateTime.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 88.8% 32 / 36 CC 4 SCAR 7.2
CC
4
Cov
86%
_attr_prop
3.5
_accessible
2.1
BEGIN
1.0
CRAP 2.1
« lib/OWL/Data/Def/OWLClass.pm ↑ Summary lib/OWL/Data/Object.pm »
1 #-----------------------------------------------------------------
2 # OWL::Data::DateTime
3 # Author: Edward Kawas <edward.kawas@gmail.com>,
4 # Martin Senger <martin.senger@gmail.com>
5 # For copyright and disclaimer see below.
6 #
7 # $Id: DateTime.pm,v 1.4 2010-01-07 21:46:39 ubuntu Exp $
8 #-----------------------------------------------------------------
9
10 package OWL::Data::DateTime;
11 3 ▶use base ("OWL::Data::Object");
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 # add versioning to this module
15 3 ▶use vars qw /$VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 $VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/;
17
18 =head1 NAME
19
20 OWL::Data::DateTime - A primitive data type for dates/times
21
22 =head1 SYNOPSIS
23
24 use OWL::Data::DateTime;
25
26 # create a DateTime
27 my $data = OWL::Data::DateTime->new (value => '1994-11-05T08:15:30-05:00');
28 my $data = OWL::Data::DateTime->new ('1994-11-05T08:15:30-05:00');
29
30 =head1 DESCRIPTION
31
32 An object representing a DateTime, a owl primitive data type.
33
34 The value of this object is stored internally as a string, but upon
35 setting it, the validity is checked. The value should follow the W3C
36 profile of the ISO-8601 specification for specifying dates and
37 times. For example:
38
39 1994-11-05T08:15:30-05:00
40
41 corresponds to November 5, 1994, 8:15:30 am, US Eastern Standard Time,
42 and
43
44 1994-11-05T13:15:30Z
45
46 corresponds to the same instant.
47
48 =head1 AUTHORS
49
50 Edward Kawas (edward.kawas [at] gmail [dot] com)
51 Martin Senger (martin.senger [at] gmail [dot] com)
52
53 =cut
54
55 #-----------------------------------------------------------------
56 # A list of allowed attribute names. See OWL::Base for details.
57 #-----------------------------------------------------------------
58
59 =head1 ACCESSIBLE ATTRIBUTES
60
61 Details are in L<OWL::Base>. Here just a list of them (additionally
62 to the attributes from the parent classes)
63
64 =over
65
66 =item B<value>
67
68 A value of this datatype. Must be a string in a particular format.
69 Defaults to time when object is initialized.
70
71 =back
72
73 =cut
74
75 {
76 3 my %_allowed =
77 (
78 value => {type => OWL::Base->DATETIME},
79 );
80
81 1 ▶ sub _accessible {
Subroutine _accessible: called CC=2 SCAR=7.2
82 1 my ($self, $attr) = @_;
83 1 ▶ exists $_allowed{$attr} or $self->SUPER::_accessible ($attr);
Branch: 1 branch
BranchTrueFalseTotal
exists $_allowed{$attr} or $self->SUPER::_accessible($attr) 1 0 1
84 }
85 4 ▶ sub _attr_prop {
Subroutine _attr_prop: called CC=3 SCAR=12.5
86 4 my ($self, $attr_name, $prop_name) = @_;
87 4 my $attr = $_allowed {$attr_name};
88 4 ▶ return ref ($attr) ? $attr->{$prop_name} : $attr if $attr;
Branch: 2 branches
BranchTrueFalseTotal
if $attr 4 0 4
ref $attr ? : 4 0 4
89 0 return $self->SUPER::_attr_prop ($attr_name, $prop_name);
90 }
91 }
92
93 #-----------------------------------------------------------------
94 # init
95 #-----------------------------------------------------------------
96 3 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod documented
97 3 my ($self) = shift;
98 3 $self->SUPER::init();
99 3 $self->primitive ('yes');
100 3 $self->value(HTTP::Date::time2isoz (HTTP::Date::str2time (HTTP::Date::parse_date (undef))));
101 }
102
103 3 1;
104 __END__
« lib/OWL/Data/Def/OWLClass.pm ↑ Summary lib/OWL/Data/Object.pm »