If I run a fragment, for example:
bool areTheyTheSame = DateTime.UtcNow == DateTime.Now
what will I get? Does DateTime return its timezone so I can compare?
My particular problem is that I am trying to create a cache-like API. If DateTime AbsoluteExpiration is required, do I need to force my API users to know whether to give me UTC or time in the time zone?
[Edit] This SO question is very important for my problem: Cache.Add absolute expiration - UTC or not?
[Edit] To clarify for future readers, DateTimeKind is what is different. Undefined DateTimeKind is often a problem, and this is what you get, for example, when retrieving from a database. Set DateTimeKind in the DateTime constructor ...
[Edit] JonSkeet wrote a great blog post condemning this behavior and offering a solution: http://noda-time.blogspot.co.uk/2011/08/what-wrong-with-datetime-anyway.html
source share