mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18752: Fixing DateTimeField storage
Work Item: 18752 --HG-- branch : 1.x
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
|
||||
namespace Orchard.ContentManagement.FieldStorage {
|
||||
public class SimpleFieldStorage : IFieldStorage {
|
||||
@@ -24,6 +25,12 @@ namespace Orchard.ContentManagement.FieldStorage {
|
||||
t = Nullable.GetUnderlyingType(t);
|
||||
}
|
||||
|
||||
// using a special case for DateTime as it would lose milliseconds otherwise
|
||||
if (typeof(T) == typeof(DateTime)) {
|
||||
var result = DateTime.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime();
|
||||
return (T) (object)result;
|
||||
}
|
||||
|
||||
return (T)Convert.ChangeType(value, t, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user