FTP file dates have wrong year for files with timestamps in the future

RESOLVED WONTFIX

Status

()

Core
Networking: FTP
RESOLVED WONTFIX
10 years ago
2 years ago

People

(Reporter: reed, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

10 years ago
If a file listed in the FTP file listings has a timestamp from the "future", Firefox will show the previous year (2006 in this case) instead of the current year (2007 in this case).

File: firefox-3.0a8pre.en-US.linux-i686.tar.bz2   8856 KB   09/18/2006   03:45:00 AM

This seems to be because it is not yet 09/18 in my current timezone (still 09/17), so the date parser falls back onto the last time 09/18 actually existed for me (maybe?). For people that the day is 09/18, the correct year (2007) is used.

If you do 'ls' in an ftp session with ftp.mozilla.org for this file:
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rwxrwxr-x    1 ftp      ftp       9068359 Sep 18 03:45 firefox-3.0a8pre.en-US.linux-i686.tar.bz2

Note that it shows the time instead of the year. If it is older than 6 months, it shows the year instead:
drwxr-xr-x    3 ftp      ftp          4096 Oct 25  2005 pub

If the timestamp to be displayed is between 'now' and 'six months before
now', then the date/time display is used.  If the time is outside that
window, then the date/year display is used.

Expected result: Firefox should display the correct year for the file even if the time is in the future.
note that the time is only in the future because the FTP server is sending the time in UTC, and Firefox is apparently interpreting it as the local timezone.
for this particular use case (timezone differences) it'd probably be sufficient to assume the time is in the future if it looks like more than 363 days ago.  The 6-months thing seems to be the practice on Linux, but who knows if that's universal across FTP servers.
vsftpd (our FTP server) does this:

  const char* p_date_format = "%b %d %H:%M";
  if (!use_localtime)
  {
    p_tm = gmtime(&p_stat->st_mtime);
  }
  else
  {
    p_tm = localtime(&p_stat->st_mtime);
  }
  /* Is this a future or 6 months old date? If so, we drop to year format */
  if (p_stat->st_mtime > local_time ||
      (local_time - p_stat->st_mtime) > 60*60*24*182)
  {
    p_date_format = "%b %d  %Y";
  }

Note that it's 6 months, and that whether to use GMT or local timezone is a config option (so by no means is the timezone being GMT going to be universal).

/bin/ls, whose output is what is modeled by most UNIX ftp servers, does this:

      six_months_ago = current_time - 31556952 / 2;
      recent = (six_months_ago <= when
		&& (when < current_time
		    || (when == current_time && when_ns <= current_time_ns)));
      fmt = long_time_format[recent];

where long_time_format is defined as:

static char const *long_time_format[2] =
  {
    N_("%b %e  %Y"),
    N_("%b %e %H:%M")
  };
From IRC discussion, is this a dup of bug#61235 (yeah, a really old 5 digit bug)?!
(Reporter)

Comment 5

10 years ago
(In reply to comment #4)
> From IRC discussion, is this a dup of bug#61235 (yeah, a really old 5 digit
> bug)?!

That bug is VERIFIED FIXED, and the issue mentioned in this bug is still clearly present, so it is not a duplicate.

Comment 6

10 years ago
the code in question is here:

http://lxr.mozilla.org/mozilla1.8/source/netwerk/streamconv/converters/ParseFTPList.cpp#1152

if you look back a bit in blame, ignoring darin's last check-in, the underlying code was apart of an initial import of Cyrus Patel's LIST Parser from 2002.

I am not really sure why we need to decrement the year if the month and date returned by the FTP is greater than today's month and date.


Status: NEW → ASSIGNED

Comment 7

10 years ago
Cyrus, do you remember why you had to adjust the year based on what month and date the server returned?

Comment 8

10 years ago
mass reassigning to nobody.
Assignee: dougt → nobody
Status: ASSIGNED → NEW
only critical fixes now
for ftp, that is :)
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.