Skip to content

Serializing & Deserializing DateTime objects #2

@pipermatt

Description

@pipermatt

The JsConfig object contains a flag called AssumeUtc. This flag causes the DateTimeSerializer to convert dates that are DateTimeKind.Unspecified on serialization to DateTimeKind.Utc using:

        if (JsConfig.AssumeUtc && dateTime.Kind == DateTimeKind.Unspecified)
        {
            dateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
        }

(lines 544-547 of NServiceKit.Text.Common.DateTimeSerializer)
However, deserialization ignores this flag and assumes that DateTimeKind.Unspecified should actually be DateTimeKind.Local.

Wouldn't it be preferable to have both serialization and deserialization honor this flag?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions