diff options
author | Homer Horwitz | 2008-10-18 15:26:41 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-10-18 15:26:41 +0000 |
commit | 3a75a54da1d973d0a8044a680c97bc2a54995548 (patch) | |
tree | 6ab775de65c290ac55b0310c828e0ade7e808403 /OpenSim | |
parent | Guard against a null ref that can prevent objects from being persisted (diff) | |
download | opensim-SC-3a75a54da1d973d0a8044a680c97bc2a54995548.zip opensim-SC-3a75a54da1d973d0a8044a680c97bc2a54995548.tar.gz opensim-SC-3a75a54da1d973d0a8044a680c97bc2a54995548.tar.bz2 opensim-SC-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 '')
-rw-r--r-- | OpenSim/Framework/Communications/Capabilities/Caps.cs | 1 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs | 3 |
3 files changed, 11 insertions, 4 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 | ||
28 | using System; | 28 | using System; |
29 | using System.Data; | 29 | using System.Data; |
30 | using System.Globalization; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.IO.Compression; | 32 | using System.IO.Compression; |
32 | using System.Net; | 33 | using 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 | ||
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs index 2763831..2bac3c7 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetXferUploader.cs | |||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
278 | CachedUserInfo userInfo = | 278 | CachedUserInfo userInfo = |
279 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | 279 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( |
280 | ourClient.AgentId); | 280 | ourClient.AgentId); |
281 | 281 | ||
282 | if (userInfo != null) | 282 | if (userInfo != null) |
283 | { | 283 | { |
284 | InventoryItemBase item = new InventoryItemBase(); | 284 | InventoryItemBase item = new InventoryItemBase(); |
@@ -296,6 +296,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
296 | item.EveryOnePermissions=0; | 296 | item.EveryOnePermissions=0; |
297 | item.NextPermissions = nextPerm; | 297 | item.NextPermissions = nextPerm; |
298 | item.Flags = (uint) wearableType; | 298 | item.Flags = (uint) wearableType; |
299 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
299 | 300 | ||
300 | userInfo.AddItem(item); | 301 | userInfo.AddItem(item); |
301 | ourClient.SendInventoryItemCreateUpdate(item); | 302 | ourClient.SendInventoryItemCreateUpdate(item); |