File modification time in LT iso UTC after import
- From: Eric Mountain <eric mountain gmail com>
- To: f-spot-list gnome org
- Subject: File modification time in LT iso UTC after import
- Date: Sat, 23 Aug 2008 23:45:55 +0200
Hello,
Been doing a few experiments as I was trying to understand how f-spot handles
time information it obtains from photo files.
It seems that if there is no EXIF data present, f-spot falls back to using the
file modification time (mtime). So far, so good.
From code I've read, f-spot attempts to convert all date-times to UTC for
storing in its DB. However, this seems not to be the case if there is no
EXIF data - instead, local time gets stored.
The import process (FileImportBackend) seems to create a Photo object using
PhotoStore.Create() which goes like this:
public Photo Create (System.Uri new_uri, [...])
[...]
using (FSpot.ImageFile img = FSpot.ImageFile.Create (orig_uri)) {
long unix_time = DbUtils.UnixTimeFromDateTime (img.Date);
Note UnixTimeFromDateTime() doesn't do a conversion to UTC. unix_time is what
gets stored subsequently in the DB.
ImageFile gets Date from Gnome.Vfs.FileInfo Ctime or Mtime fields. These
appear to be in local time. I don't know if this is expected: the
documentation I found doesn't really say anything useful on the subject:
http://www.go-mono.com/docs/monodoc.ashx?link=P%3aGnome.Vfs.FileInfo.Mtime
Since ImageFile doesn't convert the DateTime Mtime and Ctime objects it gets
to UTC, it's in fact LT that gets stored in the DB.
The patch appears trivial (i.e. just .ToUniversalTime() the Ctime and Mtime
objects in ImageFile.Date - see attachment), and seems to work OK in my
little test.
Does anyone see this breaking anything? If the patch looks OK, I'll create a
bug entry and attach it. Please let me know...
One question however: would someone be kind enough to explain what part of the
import process gets the date from the EXIF data when it is present and puts
it in the DB iso the file mtime?
Thanks,
Eric
--
Eric Mountain
http://erina.nerim.net/
Eschew obfuscation.
Index: ImageFile.cs
===================================================================
--- ImageFile.cs (revision 4274)
+++ ImageFile.cs (working copy)
@@ -142,8 +142,8 @@
// as the creation time so we try to work around that slightly
Gnome.Vfs.FileInfo info = new Gnome.Vfs.FileInfo (uri.ToString ());
- DateTime create = info.Ctime;
- DateTime write = info.Mtime;
+ DateTime create = info.Ctime.ToUniversalTime ();
+ DateTime write = info.Mtime.ToUniversalTime ();
if (create < write)
return create;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]