DarthFubuMVC/fubucore — pull request #44 by KevM (2012-06-01 16:25:18+00:00)
Title: DateTimeConverter converts ISO 8601 UTC datetimes to Local

When dates are posted to Fubu from backbone they use ISO8601 strings as UTC datetimes. They look like this:

```js
{ mydate : "2012-06-01T14:52:35.4321000Z" } //<--- the trailing Z makes it UTC
```

FubuCore's [DateTimeConverter uses DateTime.Parse](https://github.com/DarthFubuMVC/fubucore/blob/master/src/FubuCore/Conversion/DateTimeConverter.cs#l38) as a backstop to convert general strings to datetimes. Problem here is the UTC datetime coming in is converted to a localtime by DateTime.Parse.

I found [a rather detailed StackOverflow post](http://stackoverflow.com/questions/10029099/datetime-parse2012-09-30t230000-0000000z-always-converts-to-datetimekind-l) on this problem.

### Proposed Fix

I glued together a [regex to detect 8601 datetimes](http://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/) and Jon Skeet's parse exact suggestion from the SO post I linked earlier and added a special case to handle full ISO 8601 datetimes. The regex is a bit huge and the parseexact method only supports one encoding of ISO8601.

This may be a little to special case for everyone's taste.

### Do it yourself?

I am happy to implement this fix as custom stateless converter. This pull request is really to see if this should be a standard way dates are handled.

### Workaround

In your action you can call ```inputModel.datePropety.ToUniversalTime()``` where you care that your datetimes are not UTC. This can be potentially problematic as Skeet points out in the SO post.