History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: NH-1135
Type: Patch Patch
Status: Open Open
Priority: Trivial Trivial
Assignee: Unassigned
Reporter: Adam Tybor
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
NHibernate

Local & Utc DateTime Type

Created: 17/Sep/07 06:25 PM   Updated: 08/Jul/08 09:46 PM
Component/s: Core
Affects Version/s: 2.0.0.Alpha1
Fix Version/s: 2.1.0.Alpha1

File Attachments: 1. Text File NH-LocalAndUtcDateTimeType-02.patch (14 kb)
2. Text File NH-LocalAndUtcDateTimeType-Doc.patch (3 kb)
3. Text File NH-LocalAndUtcDateTimeType.patch (12 kb)



 Description  « Hide
The current DateTimeType creates a DateTime with DateTimeKind.Unspecified. By default when converting times the framework takes Unspecified to mean Local. I have added two new NHibernate Types UtcDateTime and LocalDateTime which will create a DateTime instance with the given DateTimeKind. This is very useful when you want to store UTC dates in your database.

I also modified the Equals and HashCode functions to evaluate the Kind property as well. A local time and utc time with the same values should not be equal.

Usage:
<property name="MyDate" type="UtcDateTime" />
<property name="LocalDate" type="LocalDateTime" />

The inspiration came when I needed to use Utc dates in an app and I came across this post.
http://www.milkcarton.com/blog/2007/01/19/NHibernate+DateTime+And+UTC.aspx


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Adam Tybor - 17/Sep/07 06:43 PM
Documents the new types.

Adam Tybor - 17/Sep/07 06:53 PM
Wow... I really need to pay attention what I upload here.

Here is the working patch, with passing tests for both Local and Utc, and the documentation for them.