|
Lines 60-66
sub dt_from_string {
Link Here
|
| 60 |
return if $date_string and $date_string =~ m|^0000-0|; |
60 |
return if $date_string and $date_string =~ m|^0000-0|; |
| 61 |
|
61 |
|
| 62 |
my $do_fallback = defined($date_format) ? 0 : 1; |
62 |
my $do_fallback = defined($date_format) ? 0 : 1; |
| 63 |
$tz = C4::Context->tz unless $tz;; |
63 |
my $server_tz = C4::Context->tz; |
|
|
64 |
$tz = C4::Context->tz unless $tz; |
| 64 |
|
65 |
|
| 65 |
return DateTime->now( time_zone => $tz ) unless $date_string; |
66 |
return DateTime->now( time_zone => $tz ) unless $date_string; |
| 66 |
|
67 |
|
|
Lines 126-131
sub dt_from_string {
Link Here
|
| 126 |
(?<second>\d{2}) |
127 |
(?<second>\d{2}) |
| 127 |
(\.\d{1,3})?(([Zz]$)|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9]))) |
128 |
(\.\d{1,3})?(([Zz]$)|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9]))) |
| 128 |
/xms; |
129 |
/xms; |
|
|
130 |
|
| 131 |
# Default to UTC (when 'Z' is passed) for inbound timezone. |
| 132 |
$tz = DateTime::TimeZone->new( name => 'UTC' ); |
| 129 |
} |
133 |
} |
| 130 |
elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) { |
134 |
elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) { |
| 131 |
# iso or sql format are yyyy-dd-mm[ hh:mm:ss]" |
135 |
# iso or sql format are yyyy-dd-mm[ hh:mm:ss]" |
|
Lines 168-173
sub dt_from_string {
Link Here
|
| 168 |
); |
172 |
); |
| 169 |
$ampm = $+{ampm}; |
173 |
$ampm = $+{ampm}; |
| 170 |
if ( $+{offset} ) { |
174 |
if ( $+{offset} ) { |
|
|
175 |
# If offset given, set inbound timezone using it. |
| 171 |
$tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} ); |
176 |
$tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} ); |
| 172 |
} |
177 |
} |
| 173 |
} elsif ( $do_fallback && $date_string =~ $fallback_re ) { |
178 |
} elsif ( $do_fallback && $date_string =~ $fallback_re ) { |
|
Lines 217-222
sub dt_from_string {
Link Here
|
| 217 |
( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ), |
222 |
( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ), |
| 218 |
); |
223 |
); |
| 219 |
} |
224 |
} |
|
|
225 |
$dt->set_time_zone($server_tz); |
| 220 |
return $dt; |
226 |
return $dt; |
| 221 |
} |
227 |
} |
| 222 |
|
228 |
|
| 223 |
- |
|
|