Project

General

Profile

Bug #2823

Directory listing / sort by last modified does not work on Safari

Added by fjo 2 months ago. Updated about 2 months ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
Category:
mod_dirlisting
Target version:
Start date:
2017-10-01
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

On Safari, Date.parse(at.replace(/-/g, '/')) results in NaN if at is s.th. like "2017-Oct-01 12:34:56"
Date.parse() expects "Oct 01, 2017 12:34:56"

Attached patch is suggested for latest git checkout

Associated revisions

Revision d3f4a62c (diff)
Added by gstrauss about 2 months ago

[mod_dirlisting] custom js date parse func (fixes #2823)

lighttpd mod_dirlisting produces a directory listing with the date in a
certain format, and lighttpd calls setlocale(LC_TIME, "C"), so strftime
date used in mod_dirlisting is predictable. Use a custom date parse
routine to replace Date.parse() in the javascript sorting functions.

x-ref:
"Directory listing / sort by last modified does not work on Safari"
https://redmine.lighttpd.net/issues/2823

History

#1

Updated by stbuehler 2 months ago

Maybe it would be better to dump the date in seconds since epoch as data-time attribute in the cell.

#2

Updated by gstrauss 2 months ago

HTML5 provides <time> tag, but we'd like to work with (some) older browsers, too.

Does Safari support a simplified ISO 8601 format? e.g. Date.parse("2017-Oct-01 12:34:56") or Date.parse("2017-Oct-01T12:34:56") ?

[edit: the above examples I gave are not ISO 8601 since they use "Oct" instead of "10"]

... Seems like many people recommend a custom date parse routine rather than using Date.parse().
https://stackoverflow.com/questions/31137792/date-parse-in-safari

I like stbuehler suggestion to use custom cell attribute data-time and to sort on that. Using an HTML-compliant custom attribute should be compatible with existing behavior.

#3

Updated by fjo 2 months ago

Please see the attached patch. It uses a data-time attribute. mod_dirlist.c from lighttpd2 uses an attribute named "val" for this.

#4

Updated by stbuehler 2 months ago

Please use the .patch extension for files including patches.

#5

Updated by stbuehler 2 months ago

Is the hasAttribute check really necessary? Can we check the return value of getAttribute instead?

#6

Updated by fjo 2 months ago

Yes, i meant it as a safety measure and to avoid an if-statement within "else if (sort_column == date_column) {".

#7

Updated by gstrauss about 2 months ago

  • Status changed from New to Patch Pending
  • Target version changed from 1.4.x to 1.4.46
#8

Updated by gstrauss about 2 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom