Skip to content

Fix sortable date column ordering for 12 AM (midnight) times - #27032

Open
thswlsqls wants to merge 5 commits into
jenkinsci:masterfrom
thswlsqls:fix/sortable-date-12am-midnight
Open

Fix sortable date column ordering for 12 AM (midnight) times#27032
thswlsqls wants to merge 5 commits into
jenkinsci:masterfrom
thswlsqls:fix/sortable-date-12am-midnight

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Sortable date columns parse each cell with Sortable.sorter.date.toDate(), which converts PM times (hours += 12) but has no branch for 12 AM. So "12:30 AM" keeps hours = 12 and sorts after every same-day AM time instead of before them.

sortable.js is vendored from kryogenix.org (MIT); this is a Jenkins-local correctness fix, not an upstream resync — one symmetric AM-midnight branch added beside the existing PM branch.

Testing done

No JS unit-test framework exists in this tree (jest/vitest), so no automated test was added; the change was exercised with Node and frontend lint.

Node reproduction with the file's own date_pattern, same date so only the time differs:

  • Before: toDate("12:30 AM") - toDate("1:00 AM") = +41400000 (wrong — midnight sorts last).
  • After: -1800000 (correct — midnight sorts first). Resolved hours for "12:30 AM": 12 → 0.
  • Unchanged: PM, AM 1–11, 24-hour, and date-only paths all yield identical before/after deltas.

Frontend lint clean: eslint and prettier --check on the file both pass (yarn lint:js).

Manual: a <table class="sortable"> with rows "12:30 AM" and "1:00 AM" orders midnight ahead of 1 AM after clicking the header.

Screenshots (UI changes only)

Before

N/A (sort-order behavior; not a visual change)

After

N/A

Proposed changelog entries

  • Fix sortable date column ordering so 12 AM (midnight) times sort before later morning times

Proposed changelog category

/label bug, web-ui

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, be a Bug or Improvement, and either the issue or pull request must be labeled as lts-candidate to be considered.

@comment-ops-bot comment-ops-bot Bot added bug For changelog: Minor bug. Will be listed after features web-ui The PR includes WebUI changes which may need special expertise labels Jul 5, 2026
@MarkEWaite MarkEWaite added pct-successful This PR has successfully passed the full plugin-compatibility-test suite ath-successful This PR has successfully passed the full acceptance-test-harness suite labels Jul 15, 2026
@MarkEWaite

Copy link
Copy Markdown
Contributor

@thswlsqls I was unable to find any example in Jenkins where I could test this to confirm that it works as expected. Can you provide screenshots of a place in Jenkins where a sortable time column is displayed?

@thswlsqls

Copy link
Copy Markdown
Contributor Author

Thanks for checking. You're right — no core page reaches this path: core's sortable date columns carry a data attribute (epoch millis or ISO-8601), so sorter.date never parses the visible text, and i:formatDate output on modern JDKs ("7/21/26, 12:30 AM") contains a comma the parser stops at. The AM/PM handling only fires for comma-less text like "7/21/26 12:30 AM" from plugin or user content, so this is a latent parser fix mirroring the existing PM branch rather than something visible on a core page.

The screenshots below are from a minimal harness loading the actual sortable.js from master vs. this branch, sorted ascending: before, 12:30 AM sorts after same-day PM entries; after, it sorts at the start of the day.

Before (master):

before-master-sortable-12am

After (this branch):

after-pr27032-sortable-12am

If it's not worth carrying without an in-product reproduction, I'm fine closing this — I'll leave the call to you.

@thswlsqls

Copy link
Copy Markdown
Contributor Author

@MarkEWaite Thanks again for looking at this. I replied with before/after harness screenshots on July 23 — flagging it here in case that comment didn't reach you. Whenever you have time, I'd appreciate your call on whether this is worth carrying without an in-product reproduction; I'm fine either way.

@MarkEWaite

Copy link
Copy Markdown
Contributor

@MarkEWaite Thanks again for looking at this. I replied with before/after harness screenshots on July 23 — flagging it here in case that comment didn't reach you. Whenever you have time, I'd appreciate your call on whether this is worth carrying without an in-product reproduction; I'm fine either way.

I believe that there might be a case where a sortable date column is used in the lockable resources plugin. However, that needs more time to confirm it. If it is used there, then that gives me a location where it can be tested. Let's leave the pull request open for now.

@thswlsqls

Copy link
Copy Markdown
Contributor Author

@MarkEWaite Thanks for the pointer. I checked the lockable-resources plugin and its sortable tables don't reach this path either — sorter.determine() only selects the date sorter when the cell text matches date_pattern (a leading numeric M/D/Y), while the plugin's date cells come from i:formatDate with dateStyle="medium" ("Jul 21, 2026, 12:30 AM") and its queue column renders a relative "… ago" string.

So I still don't have an in-product reproduction to offer. I'm fine either way on keeping this open or closing it — your call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ath-successful This PR has successfully passed the full acceptance-test-harness suite bug For changelog: Minor bug. Will be listed after features pct-successful This PR has successfully passed the full plugin-compatibility-test suite web-ui The PR includes WebUI changes which may need special expertise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants