//
// Copyright (c) 2008 All Right Reserved
//
// Michael S. Scherotter
// mischero@microsoft.com
// 2008-10-09
// Silverlight utility classes
namespace Synergist
{
using System;
using System.Linq;
using System.Text;
using System.Xml.Linq;
///
/// Silverlight Utilities
///
public sealed class Utility
{
///
/// Convets the value in an XML element to a nullable DateTime
///
/// an XML element
/// a nullable DateTime
public static DateTime? UnixTimeToDateTime(XElement element)
{
if (element == null)
{
return null;
}
var strUnixTime = element.Value;
if (string.IsNullOrEmpty(strUnixTime))
{
return null;
}
long unixTime = long.Parse(strUnixTime, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
var startTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return startTime.AddSeconds(unixTime);
}
}
}