aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs11
1 files changed, 8 insertions, 3 deletions
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