Skip to content

Mmissing leading zeros in DateTime year serialization and timezone offset formatting #254

Open

Description

@aliegeni

During testing of DateTime serialization, two issues were identified in the NETJSON serializer.

The first issue is related to the formatting of years with fewer than four digits. This issue has been fixed in .NET 10, but it is still reproducible on .NET Framework 4.7.2.
The second issue is related to the formatting of the local timezone offset.

  1. Years below 1000 are not zero-padded
    NETJSON does not always serialize years using the required four-digit format.
    .NET 10: works correctly.
    .NET Framework 4.7.2: leading zeros are missing.
    Expected:
    0026-09-03T15:36:22.9827969+03:00

  2. Local timezone offset is not ISO 8601 formatted
    NETJSON serializes the UTC offset without a colon:
    Actual:
    "0026-09-03T15:36:22.9827969+0300"
    Expected:
    "0026-09-03T15:36:22.9827969+03:00"

Both issues result in NETJSON producing DateTime strings that are not consistently compliant with the expected ISO 8601 representation.

Image

Activity

  1. rpgmaker commented on Sep 5, 2026

    @rpgmaker
    Owner

    @aliegeni . It is not working for 4.7.2 because I did not package a new dll for it. I will do that on the next push. I need to install 4.7.2 ( I am on Linux so will need to figure out how to make that happen)

    Thanks

  2. rpgmaker commented on Sep 5, 2026

    @rpgmaker
    Owner

    @aliegeni , i just fixed it and published the new nuget as 1.4.7 which include the old 4.7.2 . I will leave this open until you are able to test it since it take a bit of time for the package to show up in nuget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions