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 162-167 sub dt_from_string { Link Here
162
        );
166
        );
163
        $ampm = $+{ampm};
167
        $ampm = $+{ampm};
164
        if ( $+{offset} ) {
168
        if ( $+{offset} ) {
169
            # If offset given, set inbound timezone using it.
165
            $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} );
170
            $tz = DateTime::TimeZone->new( name => $+{offset} . $+{hours} . $+{minutes} );
166
        }
171
        }
167
    } elsif ( $do_fallback && $date_string =~ $fallback_re ) {
172
    } elsif ( $do_fallback && $date_string =~ $fallback_re ) {
Lines 211-216 sub dt_from_string { Link Here
211
            ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ),
216
            ( $dt_params{year} < 9999 ? ( time_zone => $tz ) : () ),
212
        );
217
        );
213
    }
218
    }
219
    $dt->set_time_zone($server_tz);
214
    return $dt;
220
    return $dt;
215
}
221
}
216
222
217
- 

Return to bug 24850