View | Details | Raw Unified | Return to bug 24850
Collapse All | Expand All

(-)a/Koha/DateUtils.pm (-2 / +7 lines)
Lines 54-60 sub dt_from_string { Link Here
54
    return if $date_string and $date_string =~ m|^0000-0|;
54
    return if $date_string and $date_string =~ m|^0000-0|;
55
55
56
    my $do_fallback = defined($date_format) ? 0 : 1;
56
    my $do_fallback = defined($date_format) ? 0 : 1;
57
    $tz = C4::Context->tz unless $tz;;
57
    my $server_tz = C4::Context->tz;
58
    $tz = C4::Context->tz unless $tz;
58
59
59
    return DateTime->now( time_zone => $tz ) unless $date_string;
60
    return DateTime->now( time_zone => $tz ) unless $date_string;
60
61
Lines 120-125 sub dt_from_string { Link Here
120
            (?<second>\d{2})
121
            (?<second>\d{2})
121
            (\.\d{1,3})?(([Zz]$)|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9])))
122
            (\.\d{1,3})?(([Zz]$)|((?<offset>[\+|\-])(?<hours>[01][0-9]|2[0-3]):(?<minutes>[0-5][0-9])))
122
        /xms;
123
        /xms;
124
125
        # Default to UTC (when 'Z' is passed) for inbound timezone.
126
        $tz = DateTime::TimeZone->new( name => 'UTC' );
123
    }
127
    }
124
    elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {
128
    elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {
125
        # iso or sql format are yyyy-dd-mm[ hh:mm:ss]"
129
        # iso or sql format are yyyy-dd-mm[ hh:mm:ss]"
Lines 156-161 sub dt_from_string { Link Here
156
            second => $+{second},
160
            second => $+{second},
157
        );
161
        );
158
        if ( $+{offset} ) {
162
        if ( $+{offset} ) {
163
            # If offset given, set inbound timezone using it.
159
            $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} );
164
            $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} );
160
        }
165
        }
161
    } elsif ( $do_fallback && $date_string =~ $fallback_re ) {
166
    } elsif ( $do_fallback && $date_string =~ $fallback_re ) {
Lines 195-200 sub dt_from_string { Link Here
195
            ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ),
200
            ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ),
196
        );
201
        );
197
    }
202
    }
203
    $dt->set_time_zone($server_tz);
198
    return $dt;
204
    return $dt;
199
}
205
}
200
206
201
- 

Return to bug 24850