Lines 40-59
use vars qw($prefformat);
Link Here
|
40 |
|
40 |
|
41 |
sub _prefformat { |
41 |
sub _prefformat { |
42 |
unless ( defined $prefformat ) { |
42 |
unless ( defined $prefformat ) { |
43 |
$prefformat = C4::Context->preference('dateformat'); |
43 |
$prefformat = C4::Context->preference('dateformat') || 'us'; |
44 |
} |
44 |
} |
45 |
return $prefformat; |
45 |
return $prefformat; |
46 |
} |
46 |
} |
47 |
|
47 |
|
48 |
sub reset_prefformat { # subroutine to clear the prefformat, called when we change it |
48 |
sub reset_prefformat { # subroutine to clear the prefformat, called when we change it |
49 |
if (defined $prefformat){ |
49 |
if (defined $prefformat){ |
50 |
$prefformat = C4::Context->preference('dateformat'); |
50 |
$prefformat = C4::Context->preference('dateformat') || 'us'; |
51 |
} |
51 |
} |
52 |
} |
52 |
} |
53 |
|
53 |
|
54 |
our %format_map = ( |
54 |
our %format_map = ( |
55 |
iso => 'yyyy-mm-dd', # plus " HH:MM:SS" |
55 |
iso => 'yyyy-mm-dd', # plus " HH:MM:SS" |
56 |
metric => 'dd/mm/yyyy', # plus " HH:MM:SS" |
56 |
metric => 'dd/mm/yyyy', # plus " HH:MM:SS" |
|
|
57 |
dmydot => 'dd.mm.yyyy', |
57 |
us => 'mm/dd/yyyy', # plus " HH:MM:SS" |
58 |
us => 'mm/dd/yyyy', # plus " HH:MM:SS" |
58 |
sql => 'yyyymmdd HHMMSS', |
59 |
sql => 'yyyymmdd HHMMSS', |
59 |
rfc822 => 'a, dd b y HH:MM:SS z ', |
60 |
rfc822 => 'a, dd b y HH:MM:SS z ', |
Lines 61-66
our %format_map = (
Link Here
|
61 |
our %posix_map = ( |
62 |
our %posix_map = ( |
62 |
iso => '%Y-%m-%d', # or %F, "Full Date" |
63 |
iso => '%Y-%m-%d', # or %F, "Full Date" |
63 |
metric => '%d/%m/%Y', |
64 |
metric => '%d/%m/%Y', |
|
|
65 |
dmydot => '%d.%m.%Y', |
64 |
us => '%m/%d/%Y', |
66 |
us => '%m/%d/%Y', |
65 |
sql => '%Y%m%d %H%M%S', |
67 |
sql => '%Y%m%d %H%M%S', |
66 |
rfc822 => '%a, %d %b %Y %H:%M:%S %z', |
68 |
rfc822 => '%a, %d %b %Y %H:%M:%S %z', |
Lines 70-75
our %dmy_subs = ( # strings to eval (after using regular ex
Link Here
|
70 |
# make arrays for POSIX::strftime() |
72 |
# make arrays for POSIX::strftime() |
71 |
iso => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', |
73 |
iso => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', |
72 |
metric => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]', |
74 |
metric => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]', |
|
|
75 |
dmydot => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]', |
73 |
us => '[(($6||0),($5||0),($4||0),$2, $1 - 1, $3 - 1900)]', |
76 |
us => '[(($6||0),($5||0),($4||0),$2, $1 - 1, $3 - 1900)]', |
74 |
sql => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', |
77 |
sql => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', |
75 |
rfc822 => '[($7, $6, $5, $2, $3, $4 - 1900, $8)]', |
78 |
rfc822 => '[($7, $6, $5, $2, $3, $4 - 1900, $8)]', |
Lines 81-87
our @days = qw(Sun Mon Tue Wed Thu Fri Sat);
Link Here
|
81 |
|
84 |
|
82 |
sub regexp ($;$) { |
85 |
sub regexp ($;$) { |
83 |
my $self = shift; |
86 |
my $self = shift; |
84 |
my $delim = qr/:?\:|\/|-/; # "non memory" cluster: no backreference |
87 |
my $delim = qr/:?\:|\/|-|\./; # "non memory" cluster: no backreference |
85 |
my $format = (@_) ? _recognize_format(shift) : ( $self->{'dateformat'} || _prefformat() ); |
88 |
my $format = (@_) ? _recognize_format(shift) : ( $self->{'dateformat'} || _prefformat() ); |
86 |
|
89 |
|
87 |
# Extra layer of checking $self->{'dateformat'}. |
90 |
# Extra layer of checking $self->{'dateformat'}. |
Lines 213-218
sub format { # get or set dateformat: iso, metric, us, etc.
Link Here
|
213 |
$self->{'dateformat'} = _recognize_format(shift); |
216 |
$self->{'dateformat'} = _recognize_format(shift); |
214 |
} |
217 |
} |
215 |
|
218 |
|
|
|
219 |
# get format string, eg. "yyyy-mm-dd" |
220 |
sub formatstr { |
221 |
my $self = shift; |
222 |
return $format_map{$self->{'dateformat'}}; |
223 |
} |
224 |
|
216 |
sub visual { |
225 |
sub visual { |
217 |
my $self = shift; |
226 |
my $self = shift; |
218 |
if (@_) { |
227 |
if (@_) { |