line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# the contents of this file are Copyright (c) 2009-2011 Daniel Norman |
2
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
3
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License as |
4
|
|
|
|
|
|
|
# published by the Free Software Foundation. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package DBR::Config::Trans::DateTime; |
7
|
18
|
|
|
18
|
|
128
|
use strict; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
873
|
|
8
|
|
|
|
|
|
|
|
9
|
18
|
|
|
18
|
|
114
|
use base 'DBR::Config::Trans'; |
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
2548
|
|
10
|
18
|
|
|
18
|
|
122
|
use DBR::Config::Trans::UnixTime; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
488
|
|
11
|
18
|
|
|
18
|
|
121
|
use POSIX qw(strftime); |
|
18
|
|
|
|
|
162
|
|
|
18
|
|
|
|
|
161
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init { |
14
|
10
|
|
|
10
|
0
|
23
|
my $self = shift; |
15
|
10
|
50
|
|
|
|
95
|
$self->{tzref} = $self->{session}->timezone_ref or return $self->_error('failed to get timezone ref'); |
16
|
10
|
|
|
|
|
90
|
return 1; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub forward{ |
20
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
21
|
2
|
|
|
|
|
4
|
my $value = shift; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
13
|
my $unixtime = Time::ParseDate::parsedate($value); |
24
|
2
|
|
|
|
|
1564
|
return bless( [$unixtime,$self->{tzref}] , 'DBR::_UXTIME'); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub backward{ |
28
|
6
|
|
|
6
|
0
|
11
|
my $self = shift; |
29
|
6
|
|
|
|
|
12
|
my $value = shift; |
30
|
|
|
|
|
|
|
|
31
|
6
|
50
|
33
|
|
|
53
|
return undef unless defined($value) && length($value); |
32
|
|
|
|
|
|
|
|
33
|
6
|
|
|
|
|
11
|
my $unixtime; |
34
|
|
|
|
|
|
|
|
35
|
6
|
50
|
|
|
|
40
|
if(ref($value) eq 'DBR::_UXTIME'){ #ahh... I know what this is |
|
|
50
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
$unixtime = $value->unixtime; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
}elsif($value =~ /^\d+$/){ # smells like a unixtime |
39
|
0
|
|
|
|
|
0
|
$unixtime = $value; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
}else{ |
42
|
6
|
|
|
|
|
38
|
$unixtime = Time::ParseDate::parsedate($value); |
43
|
|
|
|
|
|
|
|
44
|
6
|
50
|
|
|
|
4389
|
unless($unixtime){ |
45
|
0
|
|
|
|
|
0
|
$self->_error("Invalid time '$value'"); |
46
|
0
|
|
|
|
|
0
|
return (); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
419
|
return strftime ( "%D %H:%M:%S UTC", gmtime( $unixtime ) ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |