590 |
590 |
|
591 |
591 |
snprintf(buf, sizeof(buf), "%.9f", dsec);
|
592 |
592 |
buf[sizeof(buf) - 1] = 0;
|
|
593 |
buf[1] = '.'; // some locales use ','
|
593 |
594 |
subsec = buf + 1;
|
594 |
595 |
|
|
596 |
ok = false;
|
595 |
597 |
Exiv2::ExifData::iterator datePos = exifData_->findKey(ExifKey("Exif.GPSInfo.GPSDateStamp"));
|
596 |
|
if (datePos == exifData_->end()) {
|
597 |
|
datePos = exifData_->findKey(ExifKey("Exif.Photo.DateTimeOriginal"));
|
598 |
|
}
|
599 |
|
if (datePos == exifData_->end()) {
|
600 |
|
datePos = exifData_->findKey(ExifKey("Exif.Photo.DateTimeDigitized"));
|
601 |
|
}
|
602 |
|
if (datePos == exifData_->end()) {
|
|
598 |
if (datePos != exifData_->end()) {
|
|
599 |
ok = true;
|
|
600 |
if (datePos->count() != 3) ok = false;
|
|
601 |
if (ok) {
|
|
602 |
for (int i = 0; i < 3; ++i) {
|
|
603 |
if (datePos->toRational(i).second == 0) {
|
|
604 |
ok = false;
|
|
605 |
break;
|
|
606 |
}
|
|
607 |
}
|
|
608 |
}
|
|
609 |
if (!ok) {
|
603 |
610 |
#ifndef SUPPRESS_WARNINGS
|
604 |
|
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
|
611 |
std::cerr << "Warning: Failed to convert Exif.GPSInfo.GPSDateStamp to " << to << "\n";
|
605 |
612 |
#endif
|
606 |
|
return;
|
|
613 |
}
|
|
614 |
else {
|
|
615 |
year = datePos->toLong(0);
|
|
616 |
month = datePos->toLong(1);
|
|
617 |
day = datePos->toLong(2);
|
|
618 |
}
|
607 |
619 |
}
|
608 |
|
std::string value = datePos->toString();
|
609 |
|
if (sscanf(value.c_str(), "%d:%d:%d", &year, &month, &day) != 3) {
|
|
620 |
if (!ok) { // "Exif.GPSInfo.GPSDateStamp" not found or the conversion failed
|
|
621 |
datePos = exifData_->findKey(ExifKey("Exif.Photo.DateTimeOriginal"));
|
|
622 |
if (datePos == exifData_->end()) {
|
|
623 |
datePos = exifData_->findKey(ExifKey("Exif.Photo.DateTimeDigitized"));
|
|
624 |
}
|
|
625 |
if (datePos == exifData_->end()) {
|
610 |
626 |
#ifndef SUPPRESS_WARNINGS
|
611 |
|
std::cerr << "Warning: Failed to convert " << from << " to " << to
|
612 |
|
<< ", unable to parse '" << value << "'\n";
|
|
627 |
std::cerr << "Warning: Failed to convert " << from << " to " << to << "\n";
|
613 |
628 |
#endif
|
614 |
|
return;
|
|
629 |
return;
|
|
630 |
}
|
|
631 |
std::string value = datePos->toString();
|
|
632 |
if (sscanf(value.c_str(), "%d:%d:%d", &year, &month, &day) != 3) {
|
|
633 |
#ifndef SUPPRESS_WARNINGS
|
|
634 |
std::cerr << "Warning: Failed to convert " << from << " to " << to
|
|
635 |
<< ", unable to parse '" << value << "'\n";
|
|
636 |
#endif
|
|
637 |
return;
|
|
638 |
}
|
615 |
639 |
}
|
616 |
640 |
}
|
617 |
641 |
|