-
- year = datestamp / 10000;
- month = (datestamp / 100) % 100;
- day = datestamp % 100;
-
- snprintf(nice, sizeof(nice), "%4d-%02d-%02d", year, month, day);
+ int hours, minutes, seconds;
+ char date[9], atime[7];
+ int numdate, numtime;
+
+ strncpy(date, datestamp, 8);
+ date[8] = '\0';
+ numdate = atoi(date);
+ year = numdate / 10000;
+ month = (numdate / 100) % 100;
+ day = numdate % 100;
+
+ if(strlen(datestamp) <= 8) {
+ snprintf(nice, SIZEOF(nice), "%4d-%02d-%02d",
+ year, month, day);
+ }
+ else {
+ strncpy(atime, &(datestamp[8]), 6);
+ atime[6] = '\0';
+ numtime = atoi(atime);
+ hours = numtime / 10000;
+ minutes = (numtime / 100) % 100;
+ seconds = numtime % 100;
+
+ snprintf(nice, SIZEOF(nice), "%4d-%02d-%02d %02d:%02d:%02d",
+ year, month, day, hours, minutes, seconds);
+ }