Skip to content

Feature request - ISO8601 date transformer(s) #46

@mfrawley

Description

@mfrawley

Hey,
I needed this for interop with another language (scala), there are possibly other betters ways to achieve this, but as every language implements ISO8601 (de-)serialization to/from JSON differently it would be nice to have a couple of the more popular string formats of the standard ready to help people whose goal is interop with other languages/libs. I did something like this but hardcoded the 'Z' as it is commonly used/expected as a shortcut for the 0 UTC offset, but it could be made more generic.

    type ISO8601UTCDate() =
        interface ITypeTransform with
            member x.targetType () = (fun _ -> typeof<string>) ()
            member x.toTargetType value = (fun (v: obj) -> (v :?> DateTime).ToString("yyyy-MM-ddTHH:mm:ssZ") :> obj) value
            member x.fromTargetType value = (fun (v: obj) -> DateTime.Parse(v :?> string) :> obj) value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions