JamesNK/Newtonsoft.Json — pull request #239 by mj1856 (2014-04-06 00:26:04+00:00)
Title: Fix an InvalidCastException with DateTimeOffset and IsoDateTimeConverter

If you use the `IsoDateTimeConverter` with the default settings, `DateTimeOffset` values are deserialized using the machine's local time zone instead of retaining the offset in the data.

To overcome that, setting `DateParseHandling.DateTimeOffset` in the serializer settings *should* work, but that causes an `InvalidCastException`, as demonstrated by the failed unit test included in this PR.

The exception is easily fixed by testing the type of `reader.Value`. Fix included.

The question remains, should it be required to change the `DateParseHandling` option in the first place? One would think that the default behavior for parsing a `DateTimeOffset` value would be to retain the offset that was provided in the json data. That is true if you don't add any converters at all and go with the default behavior, but as soon as you add `IsoDateTimeConverter`, the behavior changes.

This is important because the `IsoDateTimeConverter` is a reasonable base class for custom converters to extend.