+ if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
+ strptime(date_str, hintfmt_arg, &tm_time);
+ } else if (strchr(date_str, ':') != NULL) {
+ /* Parse input and assign appropriately to tm_time */
+
+ if (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min,
+ &tm_time.tm_sec) == 3) {
+ /* no adjustments needed */
+ } else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour,
+ &tm_time.tm_min) == 2) {
+ /* no adjustments needed */
+ } else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon,
+ &tm_time.tm_mday, &tm_time.tm_hour,
+ &tm_time.tm_min, &tm_time.tm_sec) == 5) {
+ /* Adjust dates from 1-12 to 0-11 */
+ tm_time.tm_mon -= 1;
+ } else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon,
+ &tm_time.tm_mday,
+ &tm_time.tm_hour, &tm_time.tm_min) == 4) {
+ /* Adjust dates from 1-12 to 0-11 */
+ tm_time.tm_mon -= 1;
+ } else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year,
+ &tm_time.tm_mon, &tm_time.tm_mday,
+ &tm_time.tm_hour, &tm_time.tm_min,
+ &tm_time.tm_sec) == 6) {
+ tm_time.tm_year -= 1900; /* Adjust years */
+ tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
+ } else if (sscanf(date_str, "%d.%d.%d-%d:%d", &tm_time.tm_year,
+ &tm_time.tm_mon, &tm_time.tm_mday,
+ &tm_time.tm_hour, &tm_time.tm_min) == 5) {
+ tm_time.tm_year -= 1900; /* Adjust years */
+ tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
+ } else {
+ bb_error_msg_and_die(bb_msg_invalid_date, date_str);
+ }