- 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.0.6.0-stable
parent
48890ea349
commit
3a75a54da1
|
@ -754,6 +754,7 @@ namespace OpenSim.Framework.Communications.Capabilities
|
|||
item.BasePermissions = 2147483647;
|
||||
item.EveryOnePermissions = 0;
|
||||
item.NextPermissions = 2147483647;
|
||||
item.CreationDate = Util.UnixTimeSinceEpoch();
|
||||
|
||||
if (AddNewInventoryItem != null)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Net;
|
||||
|
@ -59,6 +60,10 @@ namespace OpenSim.Framework
|
|||
private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
|
||||
private static object XferLock = new object();
|
||||
|
||||
// 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.
|
||||
private static readonly DateTime unixEpoch =
|
||||
DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
|
||||
|
||||
#region Vector Equations
|
||||
|
||||
/// <summary>
|
||||
|
@ -290,19 +295,19 @@ namespace OpenSim.Framework
|
|||
|
||||
public static int ToUnixTime(DateTime stamp)
|
||||
{
|
||||
TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM"));
|
||||
TimeSpan t = stamp.ToUniversalTime() - unixEpoch;
|
||||
return (int) t.TotalSeconds;
|
||||
}
|
||||
|
||||
public static DateTime ToDateTime(ulong seconds)
|
||||
{
|
||||
DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
|
||||
DateTime epoch = unixEpoch;
|
||||
return epoch.AddSeconds(seconds);
|
||||
}
|
||||
|
||||
public static DateTime ToDateTime(int seconds)
|
||||
{
|
||||
DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
|
||||
DateTime epoch = unixEpoch;
|
||||
return epoch.AddSeconds(seconds);
|
||||
}
|
||||
|
||||
|
|
|
@ -296,6 +296,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
|||
item.EveryOnePermissions=0;
|
||||
item.NextPermissions = nextPerm;
|
||||
item.Flags = (uint) wearableType;
|
||||
item.CreationDate = Util.UnixTimeSinceEpoch();
|
||||
|
||||
userInfo.AddItem(item);
|
||||
ourClient.SendInventoryItemCreateUpdate(item);
|
||||
|
|
Loading…
Reference in New Issue