main.js: Fix sorting of timestamp columns - #115
Conversation
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>
|
curious: why not use |
The format paddles uses isn't supported. See https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.parse. It wants |
|
I'll verify the patch on my setup. |
|
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. |
|
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. |
|
Another idea is to drop milliseconds at all, it takes extra characters and does not give any use from such granularity to user. |
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