From a82738064436e5010268616655650ac71855668f Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 13 Jul 2014 10:22:45 -0700 Subject: [PATCH] exif: make DateTime return time.Local location when unknown timezone Change-Id: Id3ea677389e3e2e4e765116e85c0c60fb74fdff8 --- third_party/github.com/camlistore/goexif/exif/exif.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/github.com/camlistore/goexif/exif/exif.go b/third_party/github.com/camlistore/goexif/exif/exif.go index ac5f65953..bf6773a24 100644 --- a/third_party/github.com/camlistore/goexif/exif/exif.go +++ b/third_party/github.com/camlistore/goexif/exif/exif.go @@ -202,8 +202,10 @@ func (x *Exif) Walk(w Walker) error { // The error will be TagNotPresentErr if none of those tags // were found, or a generic error if the tag value was // not a string, or the error returned by time.Parse. +// +// If the EXIF lacks timezone information or GPS time, the returned +// time's Location will be time.Local. func (x *Exif) DateTime() (time.Time, error) { - // TODO(mpl): investigate the time zone question. var dt time.Time tag, err := x.Get(DateTimeOriginal) if err != nil { @@ -217,7 +219,9 @@ func (x *Exif) DateTime() (time.Time, error) { } exifTimeLayout := "2006:01:02 15:04:05" dateStr := strings.TrimRight(string(tag.Val), "\x00") - return time.Parse(exifTimeLayout, dateStr) + // TODO(bradfitz,mpl): look for timezone offset, GPS time, etc. + // For now, just always return the time.Local timezone. + return time.ParseInLocation(exifTimeLayout, dateStr, time.Local) } // String returns a pretty text representation of the decoded exif data.