Commit bf4beb7b authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Fixed MANTIS-5303 (CPF and catalogue date and date_time fields do not handle time zones properly)

parent 077f3949
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ FIELD_TYPE_color=A colour
FIELD_TYPE_password=A password (i.e. masked input)
FIELD_TYPE_date=A date
FIELD_TYPE_time=A time
FIELD_TYPE_date_time=A date and time
FIELD_TYPE_date_time=A date and time (converts to a member's timezone automatically)
FIELD_TYPE_theme_image_x=An image from the {1} directory of theme images
FIELD_TYPE_content_link_x=A link to an item of '{1}' content
FIELD_TYPE_content_link_multi_x=Multiple links to an item of '{1}' content
+6 −3
Original line number Diff line number Diff line
@@ -2450,10 +2450,11 @@ function _form_input_date(string $name, bool $required, bool $null_default, bool
    $_default_time = filter_form_field_default($name, ($default_time === null) ? '' : strval($default_time));
    $default_time = ($_default_time == '') ? null : intval($_default_time);

    if (($default_time !== null) && ($handle_timezone)) {
    if ($timezone === null) {
        $timezone = get_users_timezone();
    }

    if (($default_time !== null) && ($handle_timezone)) {
        $default_time = tz_time($default_time, $timezone);
    }

@@ -2527,6 +2528,8 @@ function _form_input_date(string $name, bool $required, bool $null_default, bool
        'MAX_DATE_MONTH' => ($year_end === null) ? '' : '12',
        'MAX_DATE_YEAR' => ($year_end === null) ? '' : strval($year_end),

        'TIMEZONE' => $timezone,

        'AUTOCOMPLETE' => $autocomplete,
        'READ_ONLY' => $read_only ? strval(1) : strval(0)
    ]);
+2 −2
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ class Hook_fields_date
                }
                $time = cms_mktime(0, 0, 0, intval($date_bits[1]), intval($date_bits[2]), @intval($date_bits[0]));
            }
            $ev = get_timezoned_date($time, false, false, $GLOBALS['FORUM_DRIVER']->get_guest_id());
            $ev = get_timezoned_date($time, false, true);
        }
        return escape_html($ev);
    }
@@ -230,7 +230,7 @@ class Hook_fields_date
        $input_name = @cms_empty_safe($field['cf_input_name']) ? ('field_' . strval($field['id'])) : $field['cf_input_name'];
        $autocomplete = ($new && !empty($field['cf_autofill_type'])) ? (($field['cf_autofill_hint'] ? ($field['cf_autofill_hint'] . ' ') : '') . $field['cf_autofill_type']) : null;

        return form_input_date($_cf_name, $_cf_description, $input_name, $field['cf_required'] == 1, ($field['cf_required'] == 0) && ($actual_value == ''), false, $time, $years_to_show, $min_year, null, true, null, true, $autocomplete);
        return form_input_date($_cf_name, $_cf_description, $input_name, $field['cf_required'] == 1, ($field['cf_required'] == 0) && ($actual_value == ''), false, $time, $years_to_show, $min_year, null, true, null, false, $autocomplete);
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ class Hook_fields_date_time
                }
                $time = cms_mktime(intval($time_bits[0]), intval($time_bits[1]), intval($time_bits[2]), intval($date_bits[1]), intval($date_bits[2]), @intval($date_bits[0]));
            }
            $ev = get_timezoned_date_time($time, false, false, $GLOBALS['FORUM_DRIVER']->get_guest_id());
            $ev = get_timezoned_date_time($time, false, false);
        }
        return escape_html($ev);
    }
@@ -270,7 +270,7 @@ class Hook_fields_date_time
        $stub = 'field_' . strval($id);

        require_code('temporal2');
        list($year, $month, $day, $hour, $minute) = post_param_date_components($stub);
        list($year, $month, $day, $hour, $minute) = post_param_date_components_utc($stub);
        if ($year === null) {
            return $editing ? STRING_MAGIC_NULL : '';
        }
+1 −1
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ function get_timezoned_date(int $timestamp, bool $use_contextual_dates = true, b
 * @param  boolean $include_time Whether to include the time in the output
 * @param  TIME $timestamp Input timestamp
 * @param  boolean $use_contextual_dates Whether contextual dates will be used
 * @param  boolean $utc_time Whether to work in UTC time
 * @param  boolean $utc_time Whether to work in UTC time (false: $timestamp is in UTC)
 * @param  ?MEMBER $member_id Member for which the date is being rendered (null: current member). Use $GLOBALS['FORUM_DRIVER']->get_guest_id() for server times
 * @return string Formatted time
 */
Loading