]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] ftp_parse_winnt_ls(): Made the fix for AM/PM more effective.
[wget] / src / ftp-ls.c
index d40261e8fe7a54ffbf2966af350bab7e89693898..ca7f43f5ab9030f8d95403a7e03b81a90d3a94f5 100644 (file)
@@ -31,7 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 # include <unistd.h>
 #endif
 #include <sys/types.h>
-#include <ctype.h>
 #include <errno.h>
 
 #include "wget.h"
@@ -411,7 +410,7 @@ ftp_parse_winnt_ls (const char *file)
   FILE *fp;
   int len;
   int year, month, day;         /* for time analysis */
-  int hour, min, sec;
+  int hour, min;
   struct tm timestruct;
 
   char *line, *tok;             /* tokenizer */
@@ -451,22 +450,23 @@ ftp_parse_winnt_ls (const char *file)
       /* Assuming the epoch starting at 1.1.1970 */
       if (year <= 70) year += 100;
 
-      /* Second column: hh:mm[AP]M */
+      /* Second column: hh:mm[AP]M, listing does not contain value for
+         seconds */
       tok = strtok(NULL,  ":");
       hour = atoi(tok);
       tok = strtok(NULL,  "M");
       min = atoi(tok);
-      /* Adjust hour from AM/PM */
+      /* Adjust hour from AM/PM. Just for the record, the sequence goes
+         11:00AM, 12:00PM, 01:00PM ... 11:00PM, 12:00AM, 01:00AM . */
       tok+=2;
+      if (hour == 12)  hour  = 0;
       if (*tok == 'P') hour += 12;
-      /* Listing does not contain value for seconds */
-      sec = 0;
 
       DEBUGP(("YYYY/MM/DD HH:MM - %d/%02d/%02d %02d:%02d\n", 
               year+1900, month, day, hour, min));
       
       /* Build the time-stamp (copy & paste from above) */
-      timestruct.tm_sec   = sec;
+      timestruct.tm_sec   = 0;
       timestruct.tm_min   = min;
       timestruct.tm_hour  = hour;
       timestruct.tm_mday  = day;