lib/MOSES/MOBY/Data/DateTime.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 40 CC 3 SCAR 17.5
CC
3
Cov
0%
_attr_prop
12.0
_accessible
2.0
init
2.0
CRAP 5.8
1 #-----------------------------------------------------------------
2 # MOSES::MOBY::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.5 2008/11/06 18:41:40 kawas Exp $
8 #-----------------------------------------------------------------
9  
10 package MOSES::MOBY::Data::DateTime;
11 use base ("MOSES::MOBY::Data::Object");
12 use strict;
13  
14 # add versioning to this module
15 use vars qw /$VERSION/;
16 $VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /: (\d+)\.(\d+)/;
17  
18 =head1 NAME
19  
20 MOSES::MOBY::Data::DateTime - A primite Moby data type for dates/times
21  
22 =head1 SYNOPSIS
23  
24 use MOSES::MOBY::Data::DateTime;
25  
26 # create a Moby DateTime
27 my $data = MOSES::MOBY::Data::DateTime->new (value => '1994-11-05T08:15:30-05:00');
28 my $data = MOSES::MOBY::Data::DateTime->new ('1994-11-05T08:15:30-05:00');
29
30 =head1 DESCRIPTION
31
32 An object representing a DateTime, a Moby 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 MOSES::MOBY::Base for details.
57 #-----------------------------------------------------------------
58  
59 =head1 ACCESSIBLE ATTRIBUTES
60  
61 Details are in L<MOSES::MOBY::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  
70 =back
71  
72 =cut
73  
74 {
75 my %_allowed =
76 (
77 value => {type => MOSES::MOBY::Base->DATETIME},
78 );
79  
80 sub _accessible {
81 my ($self, $attr) = @_;
82 exists $_allowed{$attr} or $self->SUPER::_accessible ($attr);
83 }
84 sub _attr_prop {
85 my ($self, $attr_name, $prop_name) = @_;
86 my $attr = $_allowed {$attr_name};
87 return ref ($attr) ? $attr->{$prop_name} : $attr if $attr;
88 return $self->SUPER::_attr_prop ($attr_name, $prop_name);
89 }
90 }
91  
92 #-----------------------------------------------------------------
93 # init
94 #-----------------------------------------------------------------
95 sub init {
96 my ($self) = shift;
97 $self->SUPER::init();
98 $self->primitive ('yes');
99 }
100  
101 1;
102 __END__