Skip to content

DateTime.ToString does not support "o" for ISO8601 #853

Closed
nanoframework/CoreLibrary
#158
@networkfusion

Description

@networkfusion

Details about Problem

nanoFramework area: (C# code | Nuget packages| Documentation )

VS version: (2017 | 2019 )

VS extension version:
latest

Target :
All

Description

It should be possible to return an ISO8601 compliant datetime, which is important for IoT.

Detailed repro steps so we can see the same problem

Use a program with all "supported" types of DateTime.ToString()

Other suggested things

Workaround would be DateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffZ")

Expected behaviour

Use of DateTime.ToString("o") returns a date in the format yyyy-MM-ddTHH:mm:ss.fffffffK or at least yyyy-MM-ddTHH:mm:ss.fffZ

see https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#Roundtrip for more details.

Sample Project

Screenshot

A sample implementation in .Net Core 3.1 shows:
image

Additional context

Also FYI, we do not support millisecond resolution which we should. See https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=net-5.0

I've made an effort to fix the bug

https://github.com/nanoframework/CoreLibrary/blob/develop/nanoFramework.CoreLibrary/System/Globalization/DateTimeFormat.cs needs revisiting for latest improvements in the .Net framework (including tests)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions