Date range displays incorrectly when day of month is the same but year is different

Created on 30 August 2024, 4 months ago
Updated 16 September 2024, 3 months ago

Problem/Motivation

When a date range spans years but the start date and end date are on the same day of the month, the year does not display.

Example, for a date range of December 15 2024 - January 15 2025, I see:

Dec. 15 to Jan. 15

I expect to see:

Dec. 15, 2024 to Jan. 14, 2025

Proposed resolution

In ApStyleDateFormatter::formatRange(), remove the case where only the day is the same in the start date and end date.

      elseif ($start_stamp->format('d') == $end_stamp->format('d')) {
        $format_start_date = $this->formatMonth($start_stamp) . ' j';
        $format_end_date = $this->formatMonth($end_stamp) . ' j';
      }

* We have already handled the case where the year, month and day match.

* We have already handled the case where the month and day match but not the year.

* In every remaining case where the days are the same for a date range's start date and end date, the months and years are different, so we should print both of those.

* The "else" case handles this situation, and the comment can be updated.

Additionally, the statement above does not honor the always_display_year option, so if I am wrong and there is a reason to keep this case, it should at least be updated to do so.

edit: use correct class name; ;grammar.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States calebtr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024