pravinkosurkar / metadata-extractor

Automatically exported from code.google.com/p/metadata-extractor
Apache License 2.0
0 stars 0 forks source link

Dates before "January 1, 1970, 00:00:00 GMT" should be treated as invalid #58

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version 2.6.2 under Windows7 64-bit, NTFS.

I was processing old photos I took back in 2002 using an Olympus camera and I 
ran across a case where 
ExifSubIFDDirectory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL) returns 
a date when the tag value is equal to "0000:00:00 00:00:00".

I consider this a bug for two reasons:

1. Dates under all major operating systems are defined in terms of milliseconds 
relative to "January 1, 1970, 00:00:00 GMT". Passing a negative number of 
milliseconds is invalid. If I invoke Files.setLastModifiedDate() using the date 
returned by ExifSubIFDDirectory.getDate() I get the following exception (under 
Windows, NTFS):

Exception in thread "main" java.nio.file.FileSystemException: 
D:\photos\output\DSC_0000.JPG: The parameter is incorrect.

    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.setFileTimes(WindowsFileAttributeViews.java:120)
    at sun.nio.fs.WindowsFileAttributeViews$Basic.setTimes(WindowsFileAttributeViews.java:149)
    at java.nio.file.Files.setLastModifiedTime(Files.java:2237)

2. If you navigate to the file using Windows Explorer, "Date Taken" shows up as 
"Specify date taken" (meaning, the tag is unset)

So yes, technically a date of "0000:00:00 00:00:00" could exist but practically 
speaking that's not the case. I recommend treating any date before "January 1, 
1970, 00:00:00 GMT" as if the tag is unset.

Original issue reported on code.google.com by cow...@bbs.darktech.org on 28 Sep 2012 at 12:46

GoogleCodeExporter commented 9 years ago

Original comment by drewnoakes on 16 Oct 2012 at 8:03

GoogleCodeExporter commented 9 years ago
Hello,

I don't think that is good idea to treat dates before epoch as unset. What if I 
have some scanned photos and want to write date taken into the file. 

It would be impossible, if earlier dates would be illegal.

Original comment by srnjaksr...@gmail.com on 20 Apr 2013 at 9:50

GoogleCodeExporter commented 9 years ago
srnjaksrnjak,

I have yet to see an application that treats dates earlier than epoch as legal. 
As mentioned, the file-system treats it as illegal as does Windows Explorer. 
What photo software have you used that allows these dates?

Original comment by cow...@bbs.darktech.org on 20 Apr 2013 at 11:22