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.cs22
1 files changed, 19 insertions, 3 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 856cac3..35e795b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -181,9 +181,25 @@ namespace OpenSim.Framework
181 181
182 public static int UnixTimeSinceEpoch() 182 public static int UnixTimeSinceEpoch()
183 { 183 {
184 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); 184 return ToUnixTime(DateTime.UtcNow);
185 int timestamp = (int) t.TotalSeconds; 185 }
186 return timestamp; 186
187 public static int ToUnixTime(DateTime stamp)
188 {
189 TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM"));
190 return (int)t.TotalSeconds;
191 }
192
193 public static DateTime ToDateTime(ulong seconds)
194 {
195 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
196 return epoch.AddSeconds(seconds);
197 }
198
199 public static DateTime ToDateTime(int seconds)
200 {
201 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
202 return epoch.AddSeconds(seconds);
187 } 203 }
188 204
189 public static string Md5Hash(string pass) 205 public static string Md5Hash(string pass)