Date Time Field Saving and Retrieving Different Results

Topics: Core
Nov 28, 2012 at 6:12 PM

I am wondering if I am the only one having issues with the Orchard Date Time Field. First, when I use the Date Time field it can be added but then the field does not re-appear for that content type. I have isolated this (to what I believe) is the error in that since 1.6 the field.DateTime Kind is stored as DateTimeKind of Local. This causes an error on Displaying (or editing again) because it cannot use "ConvertTimeFromUtc" with a DateTimeKind of Local. Here is some code if you too encounter this and it is a legitimate concern:

 value = DateTime.SpecifyKind(value, DateTimeKind.Unspecified);

I wish that were all but I just cannot understand why when I enter a date/time it is returned on display in a different date/time. I have stepped through the code for over two hours and all I know is that I don't understand how TimeZoneInfo.ConvertTimeFromUtc and TimeZoneInfo.ConvertTimeToUtc work / were intended to work here in Orchard. The concept seems great, the user enters a time in the field and it gets converted to UTC. Then, when retrieved, it gets converted back from UTC. However, what I enter in is not what I get back. I have messed around with the default time zone settings in the main settings area and that simply causes the time to shift one way or the other, doesn't actually fix the problem.

I will gladly give more detail and even file a bug assuming it is one - anyone else experiencing similar issues with using/editing/displaying a DateTime field?

Coordinator
Nov 28, 2012 at 10:40 PM

Please file a bug.

Nov 28, 2012 at 11:42 PM

Issue is tracked here: http://orchard.codeplex.com/workitem/19310