2013-06-09 23:50:57 +03:00
|
|
|
using System;
|
|
|
|
using Marr.Data.Converters;
|
|
|
|
using Marr.Data.Mapping;
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Datastore.Converters
|
|
|
|
{
|
|
|
|
public class UtcConverter : IConverter
|
|
|
|
{
|
2013-09-21 09:38:27 +03:00
|
|
|
public object FromDB(ConverterContext context)
|
|
|
|
{
|
|
|
|
return context.DbValue;
|
|
|
|
}
|
|
|
|
|
2013-06-09 23:50:57 +03:00
|
|
|
public object FromDB(ColumnMap map, object dbValue)
|
|
|
|
{
|
2013-09-21 09:38:27 +03:00
|
|
|
return FromDB(new ConverterContext { ColumnMap = map, DbValue = dbValue });
|
2013-06-09 23:50:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public object ToDB(object clrValue)
|
|
|
|
{
|
2013-06-10 05:10:15 +03:00
|
|
|
if (clrValue == DBNull.Value)
|
|
|
|
{
|
|
|
|
return clrValue;
|
|
|
|
}
|
|
|
|
|
2013-06-09 23:50:57 +03:00
|
|
|
var dateTime = (DateTime)clrValue;
|
|
|
|
return dateTime.ToUniversalTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Type DbType
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return typeof(DateTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|