mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#18651: Fixing loss of millisenconds when using fields
Work Item : 18651 --HG-- branch : 1.x
This commit is contained in:
@@ -8,5 +8,5 @@ e7fc05ff6137ed5459d198b2bea9a5804818b0bd src/Orchard.Web/Modules/Orchard.Forms
|
|||||||
aca1f5aeb5dd426bc80c6142afc7f2717fc6d5a1 src/Orchard.Web/Modules/Orchard.Tokens
|
aca1f5aeb5dd426bc80c6142afc7f2717fc6d5a1 src/Orchard.Web/Modules/Orchard.Tokens
|
||||||
9f98da33ee293f29a3ea4a5a7c87246c171da0f0 src/Orchard.Web/Modules/Orchard.ViewPermissions
|
9f98da33ee293f29a3ea4a5a7c87246c171da0f0 src/Orchard.Web/Modules/Orchard.ViewPermissions
|
||||||
4ed51e0e76c2aacc2de90ce9984fd00cfdfae2ce src/orchard.web/Modules/Orchard.Alias
|
4ed51e0e76c2aacc2de90ce9984fd00cfdfae2ce src/orchard.web/Modules/Orchard.Alias
|
||||||
109844c63717ca7f881fb126a845184cca8de6f6 src/orchard.web/Modules/Orchard.Projections
|
d3a8dac3aca8deb5fd45e8864a4273a88a8741ee src/orchard.web/Modules/Orchard.Projections
|
||||||
0826b86677cd77cfb05342b3ba570f522dc3e786 src/orchard.web/modules/Orchard.Fields
|
0826b86677cd77cfb05342b3ba570f522dc3e786 src/orchard.web/modules/Orchard.Fields
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
@@ -200,6 +201,14 @@ namespace Orchard.Tests.Data {
|
|||||||
Assert.That(two.Name, Is.EqualTo("two"));
|
Assert.That(two.Name, Is.EqualTo("two"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StoringDateTimeDoesntRemovePrecision() {
|
||||||
|
_fooRepos.Create(new FooRecord { Name = "one", Timespan = DateTime.Parse("2001-01-01 16:28:21.489", CultureInfo.InvariantCulture) });
|
||||||
|
|
||||||
|
var one = _fooRepos.Fetch(f => f.Name == "one").Single();
|
||||||
|
|
||||||
|
Assert.That(one.Name, Is.EqualTo("one"));
|
||||||
|
Assert.That(one.Timespan.Value.Millisecond, Is.EqualTo(489));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
namespace Orchard.Tests.Records {
|
namespace Orchard.Tests.Records {
|
||||||
public class FooRecord {
|
public class FooRecord {
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
public virtual string Name { get; set; }
|
public virtual string Name { get; set; }
|
||||||
|
public virtual DateTime? Timespan { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -28,7 +28,15 @@ namespace Orchard.ContentManagement.FieldStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Set<T>(string name, T value) {
|
public void Set<T>(string name, T value) {
|
||||||
Setter(name, typeof(T), Convert.ToString(value, CultureInfo.InvariantCulture));
|
|
||||||
|
// using a special case for DateTime as it would lose milliseconds otherwise
|
||||||
|
if (typeof(T) == typeof(DateTime)) {
|
||||||
|
var text = ((DateTime)(object)value).ToString("o", CultureInfo.InvariantCulture);
|
||||||
|
Setter(name, typeof(T), text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Setter(name, typeof (T), Convert.ToString(value, CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user