]> sjero.net Git - wget/blobdiff - src/ftp-ls.c
[svn] Make seconds optional in VMS time specification.
[wget] / src / ftp-ls.c
index 22d1887aaba48ca458321b6e7993b503ce2a81bc..338c1a4e27b3b270d3708e72342dbbd3d5b1c25a 100644 (file)
@@ -456,9 +456,11 @@ ftp_parse_winnt_ls (const char *file)
       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 (*tok == 'P') hour = (hour + 12) % 24;
+      if (hour == 12)  hour  = 0;
+      if (*tok == 'P') hour += 12;
 
       DEBUGP(("YYYY/MM/DD HH:MM - %d/%02d/%02d %02d:%02d\n", 
               year+1900, month, day, hour, min));
@@ -582,6 +584,7 @@ ftp_parse_vms_ls (const char *file)
   /* Line loop to end of file: */
   while ((line = read_whole_line (fp)))
     {
+      char *p;
       i = clean_line (line);
       if (!i) break;
 
@@ -668,13 +671,17 @@ ftp_parse_vms_ls (const char *file)
       year = atoi(tok)-1900;
       DEBUGP(("date parsed\n"));
 
-      /* Fourth/Third column: Time hh:mm:ss */
-      tok = strtok(NULL,  ":");
-      hour = atoi(tok);
-      tok = strtok(NULL,  ":");
-      min = atoi(tok);
-      tok = strtok(NULL,  " ");
-      sec = atoi(tok);
+      /* Fourth/Third column: Time hh:mm[:ss] */
+      tok = strtok (NULL, " ");
+      hour = min = sec = 0;
+      p = tok;
+      hour = atoi (p);
+      for (; *p && *p != ':'; ++p);
+      if (*p)
+       min = atoi (++p);
+      for (; *p && *p != ':'; ++p);
+      if (*p)
+       sec = atoi (++p);
 
       DEBUGP(("YYYY/MM/DD HH:MM:SS - %d/%02d/%02d %02d:%02d:%02d\n", 
               year+1900, month, day, hour, min, sec));