Skip to content

main.js: Fix sorting of timestamp columns - #115

Merged
djgalloway merged 1 commit into
mainfrom
fix-locked-since-sort
Jul 31, 2026
Merged

main.js: Fix sorting of timestamp columns#115
djgalloway merged 1 commit into
mainfrom
fix-locked-since-sort

Conversation

@djgalloway

Copy link
Copy Markdown
Contributor

paddles serializes timestamps as "YYYY-MM-DD HH:MM:SS[.ffffff]". tablesorter's auto-detected shortDate parser mangles the fractional seconds (its format() replaces the "." with "/"), so new Date() fails and every cell in e.g. the nodes page's Locked Since column gets an empty sort key, making the sort a no-op.

Register a custom parser that converts these timestamps to epoch milliseconds via Date.UTC(), handling both the usual microsecond suffix and its absence when microseconds are zero.

Fixes: https://tracker.ceph.com/issues/59629

paddles serializes timestamps as "YYYY-MM-DD HH:MM:SS[.ffffff]".
tablesorter's auto-detected shortDate parser mangles the fractional
seconds (its format() replaces the "." with "/"), so new Date() fails
and every cell in e.g. the nodes page's Locked Since column gets an
empty sort key, making the sort a no-op.

Register a custom parser that converts these timestamps to epoch
milliseconds via Date.UTC(), handling both the usual microsecond
suffix and its absence when microseconds are zero.

Fixes: https://tracker.ceph.com/issues/59629

Signed-off-by: David Galloway <david.galloway@ibm.com>
@dmick
dmick requested review from Copilot and zmc and removed request for Copilot July 20, 2026 23:01
@zmc

zmc commented Jul 20, 2026

Copy link
Copy Markdown
Member

curious: why not use Date.parse() ?

@djgalloway

Copy link
Copy Markdown
Contributor Author

curious: why not use Date.parse() ?

The format paddles uses isn't supported. See https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse.

It wants YYYY-MM-DDTHH:mm:ss.sss, (literal T, three fractional second places) paddles uses YYYY-MM-DD HH:MM:SS.ffffff

@kshtsk

kshtsk commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

I'll verify the patch on my setup.

@kshtsk

kshtsk commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

I confirm the sorting does not work, and also I can say the patch looks fixing the issue, if @zmc doesn't have any other objections to the code itself. Nice catch @djgalloway, nice catch.

@kshtsk

kshtsk commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Only thing I dislike is bounding to UTC, however, we have some sacrosanct environment bound to UTC, so I guess it's okay to merge it now, and adjust in follow up PRs.

@kshtsk

kshtsk commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Another idea is to drop milliseconds at all, it takes extra characters and does not give any use from such granularity to user.

@djgalloway
djgalloway merged commit dfffdeb into main Jul 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants