Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local date extracted instead of UTC #84

Open
morgan-wild opened this issue Dec 20, 2021 · 2 comments
Open

Local date extracted instead of UTC #84

morgan-wild opened this issue Dec 20, 2021 · 2 comments

Comments

@morgan-wild
Copy link

I have an issue with the date fields (CreateDate, ModifyDate, DateTimeOriginal) and time offsets.

The date extracted from these fields is formated like an UTC (GMT 0) date but the issue I have is the value I read matches with the local time.

For example, if I take a picture in France at 11:39:54 (GMT+1), the value I extract for CreateDate will be 2021-12-19T11:39:54.000Z instead of 2021-12-19T10:39:54.000Z.

This is a known issue? Do you think it is my devices which write some bad data?

Best regards.

@renchap
Copy link

renchap commented Jan 4, 2022

Most cameras do not store the timezone in their EXIF data, and you dont have any way to know which timezone the date stored in EXIF is. The current code for handling the dates is here:

// can be '2009-09-23 17:40:52 UTC' or '2010:07:06 20:45:12'
function reviveDate(string) {
if (typeof string !== 'string') return undefined
var [year, month, day, hours, minutes, seconds] = string.trim().split(/[-: ]/g).map(Number)
var date = new Date(year, month - 1, day)
if (!Number.isNaN(hours) && !Number.isNaN(minutes) && !Number.isNaN(seconds)) {
date.setHours(hours)
date.setMinutes(minutes)
date.setSeconds(seconds)
}
if (Number.isNaN(+date))
return string
else
return date
}

If there is a timezone indication it is dropped, and the date is created as if it was using the current timezone.

You can check the exact value in your file using https://exif.tools. If a timezone is indeed included, then we should probably patch the current implementation to take it into account. You can also use the reviveValues: false option to not have Exifr parse the field, and then do it yourself.

@morgan-wild
Copy link
Author

Thank you for your reply!

I understand. By luck, in my project I developed a time offset compensation using a QRCode, it was initialy made to fix small offsets (generally for some seconds between the clock of the camera and my reference clock) but it also fixes this kind of issue.

Thank you I know the reason, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants