Commit fbb5cb14 authored by Joseph Bylund's avatar Joseph Bylund Committed by Jim Nelson

Wrong date for Pentax K-5 AVI: Closes #7054

An improved date-parsing routine to help eliminate future issues
with oddball date formats in videos.
parent 3a424909
......@@ -433,37 +433,30 @@ private class AVIMetadataLoader {
if (sdate.length == 0) {
return 0;
}
Date date = Date();
uint seconds = 0;
if (sdate[0].isdigit() && !sdate.contains("/")) {
int year, month, day, hour, min, sec;
string weekday = "";
string monthstr = "";
if (sdate[0].isdigit()) {
// Format is: 2005:08:17 11:42:43
int year, month, day, hour, min, sec;
int result = sdate.scanf("%d:%d:%d %d:%d:%d", out year, out month, out day,
out hour, out min, out sec);
if (6 != result) {
return 0; // Error
}
date.set_dmy((DateDay) day, (DateMonth) month, (DateYear) year);
seconds = sec + min * 60 + hour * 3600;
} else if (sdate[0].isdigit()) {
// This is specific to Casio cameras.
// Format is: 2010/11/30/ 19:42
int year, month, day, hour, min;
int result = sdate.scanf("%d/%d/%d/ %d:%d", out year, out month, out day,
out hour, out min);
if (5 != result) {
return 0; // Error
// Format is: 2010/11/30 19:42
string tmp = sdate.dup();
tmp.canon("0123456789 ", ' '); // strip everything but numbers and spaces
sec = 0;
int result = tmp.scanf("%d %d %d %d %d %d", out year, out month, out day, out hour, out min, out sec);
if(result < 5) {
return 0;
}
date.set_dmy((DateDay) day, (DateMonth) month, (DateYear) year);
seconds = min * 60 + hour * 3600;
seconds = sec + min * 60 + hour * 3600;
} else {
// Format is: Mon Mar 3 09:44:56 2008
int year, day, hour, min, sec;
string weekday = "";
string monthstr = "";
int result = sdate.scanf("%3s %3s %d %d:%d:%d %d", weekday, monthstr, out day, out hour,
out min, out sec, out year);
if (7 != result) {
if(7 != sdate.scanf("%3s %3s %d %d:%d:%d %d", weekday, monthstr, out day, out hour,
out min, out sec, out year)) {
return 0; // Error
}
date.set_dmy((DateDay) day, month_from_string(monthstr), (DateYear) year);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment