Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.0] Fix an issue with wrong date on event creating #8090

Open
wants to merge 2 commits into
base: release-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sources/Actions/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,12 @@ public static function convertDateToEnglish(string $date): string
$replacements += array_combine(array_map('strtolower', Lang::$txt['days_short']), [
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
]);

// Fix for languages those do not use AM/PM
if (Lang::$txt['time_am'] == ' ' && Lang::$txt['time_pm'] == ' ') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use trim() here and === ''

return strtr(strtolower($date), $replacements);
}

// Find all possible variants of AM and PM for this language.
$replacements[strtolower(Lang::$txt['time_am'])] = 'AM';
$replacements[strtolower(Lang::$txt['time_pm'])] = 'PM';
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/Calendar.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ function template_event_post()
<div class="event_options_left" id="event_time_input">
<div>
<span class="label">', Lang::$txt['start'], '</span>
<input type="text" name="start_date" id="start_date" value="', trim(Utils::$context['event']['start_date_orig']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input start" data-type="date">
<input type="text" name="start_date" id="start_date" value="', trim(Utils::$context['event']['start_date']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input start" data-type="date">
<input type="text" name="start_time" id="start_time" maxlength="11" value="', Utils::$context['event']['start_time_orig'], '" tabindex="', Utils::$context['tabindex']++, '" class="time_input start" data-type="time"', !empty(Utils::$context['event']['allday']) ? ' disabled' : '', '>
</div>
<div>
<span class="label">', Lang::$txt['end'], '</span>
<input type="text" name="end_date" id="end_date" value="', trim(Utils::$context['event']['end_date_orig']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input end" data-type="date"', Config::$modSettings['cal_maxspan'] == 1 ? ' disabled' : '', '>
<input type="text" name="end_date" id="end_date" value="', trim(Utils::$context['event']['end_date']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input end" data-type="date"', Config::$modSettings['cal_maxspan'] == 1 ? ' disabled' : '', '>
<input type="text" name="end_time" id="end_time" maxlength="11" value="', Utils::$context['event']['end_time_orig'], '" tabindex="', Utils::$context['tabindex']++, '" class="time_input end" data-type="time"', !empty(Utils::$context['event']['allday']) ? ' disabled' : '', '>
</div>
</div><!-- #event_time_input -->
Expand Down
4 changes: 2 additions & 2 deletions Themes/default/Post.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ function addPollOption()
<div class="event_options_left" id="event_time_input">
<div>
<span class="label">', Lang::$txt['start'], '</span>
<input type="text" name="start_date" id="start_date" value="', trim(Utils::$context['event']['start_date_orig']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input start" data-type="date">
<input type="text" name="start_date" id="start_date" value="', trim(Utils::$context['event']['start_date']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input start" data-type="date">
<input type="text" name="start_time" id="start_time" maxlength="11" value="', Utils::$context['event']['start_time_orig'], '" tabindex="', Utils::$context['tabindex']++, '" class="time_input start" data-type="time"', !empty(Utils::$context['event']['allday']) ? ' disabled' : '', '>
</div>
<div>
<span class="label">', Lang::$txt['end'], '</span>
<input type="text" name="end_date" id="end_date" value="', trim(Utils::$context['event']['end_date_orig']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input end" data-type="date"', Config::$modSettings['cal_maxspan'] == 1 ? ' disabled' : '', '>
<input type="text" name="end_date" id="end_date" value="', trim(Utils::$context['event']['end_date']), '" tabindex="', Utils::$context['tabindex']++, '" class="date_input end" data-type="date"', Config::$modSettings['cal_maxspan'] == 1 ? ' disabled' : '', '>
<input type="text" name="end_time" id="end_time" maxlength="11" value="', Utils::$context['event']['end_time_orig'], '" tabindex="', Utils::$context['tabindex']++, '" class="time_input end" data-type="time"', !empty(Utils::$context['event']['allday']) ? ' disabled' : '', '>
</div>
</div>
Expand Down