[PATCH] F-spot: Allow dates before 1970



Larry,

Attached patch 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.0.orig/src/Db.cs	2005-03-19 14:24:32.000000000 +0100
+++ f-spot-0.1.0.new/src/Db.cs	2005-08-17 19:48:09.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.0.orig/src/ImportStore.cs	2005-03-19 14:24:32.000000000 +0100
+++ f-spot-0.1.0.new/src/ImportStore.cs	2005-08-17 19:48:09.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.0.orig/src/PhotoStore.cs	2005-08-11 23:02:21.000000000 +0200
+++ f-spot-0.1.0.new/src/PhotoStore.cs	2005-08-17 19:49:20.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))
@@ -538,7 +538,7 @@
 
 	public Photo Create (DateTime time_in_utc, string path, out Pixbuf thumbnail)
 	{
-		uint unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
+		long unix_time = DbUtils.UnixTimeFromDateTime (time_in_utc);
 
 		SqliteCommand command = new SqliteCommand ();
 		command.Connection = Connection;
@@ -741,7 +741,7 @@
 
 		if (reader.Read ()) {
 			photo = new Photo (id,
-					   Convert.ToUInt32 (reader [0]),
+					   Convert.ToInt64 (reader [0]),
 					   reader [1].ToString (),
 					   reader [2].ToString ());
 
@@ -789,7 +789,7 @@
 
 		if (reader.Read ()) {
 			photo = new Photo (Convert.ToUInt32 (reader [0]),
-					   Convert.ToUInt32 (reader [1]),
+					   Convert.ToInt64 (reader [1]),
 					   directory_path,
 					   filename);
 
@@ -1003,7 +1003,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]