2013-05-11 08:59:42 +03:00
|
|
|
using System;
|
|
|
|
using System.Globalization;
|
|
|
|
using Marr.Data.Converters;
|
|
|
|
using Marr.Data.Mapping;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore.Converters
|
|
|
|
{
|
|
|
|
public class UtcDateTimeConverter : IConverter
|
|
|
|
{
|
|
|
|
public Type DbType
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return typeof(DateTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public object FromDB(ColumnMap map, object dbValue)
|
|
|
|
{
|
|
|
|
if (dbValue != null && dbValue != DBNull.Value)
|
|
|
|
{
|
|
|
|
var dateTime = (DateTime)dbValue;
|
|
|
|
dateTime = new DateTime(dateTime.Ticks, DateTimeKind.Local);
|
|
|
|
return dateTime.ToUniversalTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public object ToDB(object clrValue)
|
|
|
|
{
|
2013-05-11 09:16:10 +03:00
|
|
|
if (clrValue != null && clrValue != DBNull.Value)
|
2013-05-11 08:59:42 +03:00
|
|
|
{
|
|
|
|
return ((DateTime)clrValue).ToUniversalTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
return DBNull.Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|