[PATCH] F-spot: Allow dates before 1970
- From: Fredrik Noring <noring nocrew org>
- To: Larry Ewing <lewing novell com>
- Cc: f-spot-list gnome org
- Subject: [PATCH] F-spot: Allow dates before 1970
- Date: Sun, 09 Oct 2005 22:51:41 +0200
Larry,
Attached patch (updated for 0.1.3) fixes the problem with photos dated
before 1970. It implements negative unix time integers so that old
databases will remain compatible with the patch applied.
Db.cs | 6 +++---
ImportStore.cs | 4 ++--
PhotoStore.cs | 12 ++++++------
3 files changed, 11 insertions(+), 11 deletions(-)
Please consider applying this,
Fredrik
--- f-spot-0.1.3.orig/src/Db.cs 2005-09-29 09:56:25.000000000 +0200
+++ f-spot-0.1.3.new/src/Db.cs 2005-10-09 22:41:59.000000000 +0200
@@ -168,14 +168,14 @@
public class DbUtils {
- public static DateTime DateTimeFromUnixTime (uint unix_time)
+ public static DateTime DateTimeFromUnixTime (long unix_time)
{
DateTime date_time = new DateTime (1970, 1, 1).ToLocalTime ();
return date_time.AddSeconds (unix_time);
}
- public static uint UnixTimeFromDateTime (DateTime date_time)
+ public static long UnixTimeFromDateTime (DateTime date_time)
{
- return (uint) (date_time - new DateTime (1970, 1, 1).ToLocalTime ()).TotalSeconds;
+ return (long) (date_time - new DateTime (1970, 1, 1).ToLocalTime ()).TotalSeconds;
}
}
--- f-spot-0.1.3.orig/src/ImportStore.cs 2005-09-29 09:56:25.000000000 +0200
+++ f-spot-0.1.3.new/src/ImportStore.cs 2005-10-09 22:41:59.000000000 +0200
@@ -15,7 +15,7 @@
}
}
- public Import (uint id, uint unix_time)
+ public Import (uint id, long unix_time)
: base (id)
{
time = DbUtils.DateTimeFromUnixTime (unix_time);
@@ -51,7 +51,7 @@
public Import Create (DateTime time_in_utc)
{
- uint unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
+ long unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
SqliteCommand command = new SqliteCommand ();
command.Connection = Connection;
--- f-spot-0.1.3.orig/src/PhotoStore.cs 2005-09-29 09:56:25.000000000 +0200
+++ f-spot-0.1.3.new/src/PhotoStore.cs 2005-10-09 22:42:16.000000000 +0200
@@ -384,7 +384,7 @@
// Constructor
- public Photo (uint id, uint unix_time, string directory_path, string name)
+ public Photo (uint id, long unix_time, string directory_path, string name)
: base (id)
{
time = DbUtils.DateTimeFromUnixTime (unix_time);
@@ -399,7 +399,7 @@
AddVersionUnsafely (OriginalVersionId, Mono.Posix.Catalog.GetString ("Original"));
}
- public Photo (uint id, uint unix_time, string path)
+ public Photo (uint id, long unix_time, string path)
: this (id, unix_time,
System.IO.Path.GetDirectoryName (path),
System.IO.Path.GetFileName (path))
@@ -532,7 +532,7 @@
public Photo Create (string path, out Pixbuf thumbnail)
{
FSpot.ImageFile img = FSpot.ImageFile.Create (path);
- uint unix_time = DbUtils.UnixTimeFromDateTime (img.Date);
+ long unix_time = DbUtils.UnixTimeFromDateTime (img.Date);
string description = img.Description != null ? img.Description : "";
SqliteCommand command = new SqliteCommand ();
command.Connection = Connection;
@@ -736,7 +736,7 @@
if (reader.Read ()) {
photo = new Photo (id,
- Convert.ToUInt32 (reader [0]),
+ Convert.ToInt64 (reader [0]),
reader [1].ToString (),
reader [2].ToString ());
@@ -784,7 +784,7 @@
if (reader.Read ()) {
photo = new Photo (Convert.ToUInt32 (reader [0]),
- Convert.ToUInt32 (reader [1]),
+ Convert.ToInt64 (reader [1]),
directory_path,
filename);
@@ -998,7 +998,7 @@
if (photo == null) {
photo = new Photo (id,
- Convert.ToUInt32 (reader [1]),
+ Convert.ToInt64 (reader [1]),
reader [2].ToString (),
reader [3].ToString ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]