aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorHomer Horwitz2008-10-18 15:26:41 +0000
committerHomer Horwitz2008-10-18 15:26:41 +0000
commit3a75a54da1d973d0a8044a680c97bc2a54995548 (patch)
tree6ab775de65c290ac55b0310c828e0ade7e808403 /OpenSim/Framework
parentGuard against a null ref that can prevent objects from being persisted (diff)
downloadopensim-SC_OLD-3a75a54da1d973d0a8044a680c97bc2a54995548.zip
opensim-SC_OLD-3a75a54da1d973d0a8044a680c97bc2a54995548.tar.gz
opensim-SC_OLD-3a75a54da1d973d0a8044a680c97bc2a54995548.tar.bz2
opensim-SC_OLD-3a75a54da1d973d0a8044a680c97bc2a54995548.tar.xz
- Fix Util.UnixTimeSinceEpoch:
* Unix epoch starts at midnight, not at 8:00am * All date/time handling should be done in UTC in the server, not in the local timezone. * Refactor out repeated computation of a constant value - Added setting of CreationTime to some places where inventoryitems are created This fixes Mantis#2390.
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/Capabilities/Caps.cs1
-rw-r--r--OpenSim/Framework/Util.cs11
2 files changed, 9 insertions, 3 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs
index fd43e89..28e56da 100644
--- a/OpenSim/Framework/Communications/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs
@@ -754,6 +754,7 @@ namespace OpenSim.Framework.Communications.Capabilities
754 item.BasePermissions = 2147483647; 754 item.BasePermissions = 2147483647;
755 item.EveryOnePermissions = 0; 755 item.EveryOnePermissions = 0;
756 item.NextPermissions = 2147483647; 756 item.NextPermissions = 2147483647;
757 item.CreationDate = Util.UnixTimeSinceEpoch();
757 758
758 if (AddNewInventoryItem != null) 759 if (AddNewInventoryItem != null)
759 { 760 {
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 0f0aa47..c5334a8 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Data; 29using System.Data;
30using System.Globalization;
30using System.IO; 31using System.IO;
31using System.IO.Compression; 32using System.IO.Compression;
32using System.Net; 33using System.Net;
@@ -59,6 +60,10 @@ namespace OpenSim.Framework
59 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; 60 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
60 private static object XferLock = new object(); 61 private static object XferLock = new object();
61 62
63 // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC.
64 private static readonly DateTime unixEpoch =
65 DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
66
62 #region Vector Equations 67 #region Vector Equations
63 68
64 /// <summary> 69 /// <summary>
@@ -290,19 +295,19 @@ namespace OpenSim.Framework
290 295
291 public static int ToUnixTime(DateTime stamp) 296 public static int ToUnixTime(DateTime stamp)
292 { 297 {
293 TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM")); 298 TimeSpan t = stamp.ToUniversalTime() - unixEpoch;
294 return (int) t.TotalSeconds; 299 return (int) t.TotalSeconds;
295 } 300 }
296 301
297 public static DateTime ToDateTime(ulong seconds) 302 public static DateTime ToDateTime(ulong seconds)
298 { 303 {
299 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM"); 304 DateTime epoch = unixEpoch;
300 return epoch.AddSeconds(seconds); 305 return epoch.AddSeconds(seconds);
301 } 306 }
302 307
303 public static DateTime ToDateTime(int seconds) 308 public static DateTime ToDateTime(int seconds)
304 { 309 {
305 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM"); 310 DateTime epoch = unixEpoch;
306 return epoch.AddSeconds(seconds); 311 return epoch.AddSeconds(seconds);
307 } 312 }
308 313