Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Correct #217
Browse files Browse the repository at this point in the history
  • Loading branch information
hdsdi3g committed Dec 19, 2016
1 parent e7ff2b5 commit 02821c8
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions app/hd3gtv/mydmam/transcode/mtdgenerator/FFprobeAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ public ContainerEntryResult processFull(Container container, StoppableProcessing
}

private static final DateFormat[] formats = { new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"), new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"),
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), new SimpleDateFormat("yyyy-MM-dd") };
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") };
private static final DateFormat formats_ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final DateFormat formats_hms = new SimpleDateFormat("yyyy-MM-dd");

private static Date bruteForceDateParser(String date_value) {
for (int pos = 0; pos < formats.length; pos++) {
Expand All @@ -280,6 +282,22 @@ private static Date bruteForceDateParser(String date_value) {
} catch (ParseException e) {
}
}

/**
* UUID and date format can clash.
*/
if (date_value.length() == "yyyy-MM-dd HH:mm:ss".length()) {
try {
return formats_ymdhms.parse(date_value);
} catch (ParseException e) {
}
} else if (date_value.length() == "yyyy-MM-dd".length()) {
try {
return formats_hms.parse(date_value);
} catch (ParseException e) {
}
}

return null;
}

Expand All @@ -301,7 +319,10 @@ private static void patchTagDate(JsonObject tags) {
value = entry.getValue().getAsString();
parsed_date = bruteForceDateParser(value);
if (parsed_date != null) {
new_values.put(key, new JsonPrimitive(parsed_date.getTime()));
long date = parsed_date.getTime();
if (date > 1) {
new_values.put(key, new JsonPrimitive(parsed_date.getTime()));
}
}
}

Expand Down

0 comments on commit 02821c8

Please sign in to comment.