Mercurial > repos > IBBoard
view UnixTimestamp.cs @ 10:3b7a321e7c4c
Fixes #4 - unexpected exception in translations
* Call private language load method to avoid check and exception
* Don't null the local table after we've set a default
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 12:02:36 +0000 |
parents | 961030992bd2 |
children | 0352fa33ee8f |
line wrap: on
line source
using System; namespace IBBoard { /// <summary> /// Summary description for UnixTimestamp. /// </summary> public class UnixTimestamp { private long stamp; private static DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToUniversalTime(); public UnixTimestamp(DateTime date) { stamp = GetTimestamp(date); } public UnixTimestamp(long timestamp) { stamp = timestamp; } public DateTime GetDate() { return unixEpoch.AddSeconds(stamp); } public DateTime GetDate(int timestamp) { return unixEpoch.AddSeconds(timestamp); } public long GetTimestamp() { return stamp; } public static long GetTimestamp(DateTime date) { TimeSpan span = date.ToUniversalTime() - unixEpoch; return (long)span.TotalSeconds; } } }