[PATCH] F-spot: Allow dates before 1970



Hi Larry,

Here's my third take to address 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(-)

Fredrik

--- f-spot-0.0.13.orig/src/Db.cs	2005-02-14 07:15:00.000000000 +0100
+++ f-spot-0.0.13.new/src/Db.cs	2005-07-10 21:13:40.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.0.13.orig/src/ImportStore.cs	2003-11-22 19:47:20.000000000 +0100
+++ f-spot-0.0.13.new/src/ImportStore.cs	2005-07-10 21:13:07.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.0.13.orig/src/PhotoStore.cs	2005-05-09 07:52:29.000000000 +0200
+++ f-spot-0.0.13.new/src/PhotoStore.cs	2005-07-11 19:41:40.000000000 +0200
@@ -361,7 +361,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);
@@ -376,7 +376,7 @@
 		AddVersionUnsafely (OriginalVersionId, "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))
@@ -517,7 +517,7 @@
 			throw new Exception ("Only jpeg files supported");
 
 
-		uint unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
+		long unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
 
 		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
@@ -718,7 +718,7 @@
 
 		if (reader.Read ()) {
 			photo = new Photo (id,
-					   Convert.ToUInt32 (reader [0]),
+					   Convert.ToInt64 (reader [0]),
 					   reader [1].ToString (),
 					   reader [2].ToString ());
 
@@ -766,7 +766,7 @@
 
 		if (reader.Read ()) {
 			photo = new Photo (Convert.ToUInt32 (reader [0]),
-					   Convert.ToUInt32 (reader [1]),
+					   Convert.ToInt64 (reader [1]),
 					   directory_path,
 					   filename);
 
@@ -980,7 +980,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]