Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Yaml] Allow dumping DateTimeInterface objects with milliseconds or microseconds #48920

Closed
@dustinwilson

Description

@dustinwilson

Description

At present the Yaml component will parse date formats such as 2023-01-08T16:18:25.213Z but it can't dump them, instead only using the 'c' format which doesn't contain milliseconds. I would like to suggest having Inline use 'Y-m-d\TH:i:s.vO' and 'Y-m-d\TH:i:s.uO' instead when the DateTimeInterface object being dumped contains milliseconds or microseconds respectively. It wouldn't require any additional flags but instead have it intelligently choose which format to output based on how precise the DateTimeInterface is.

Example

Currently

In:

date: 2023-01-08T16:18:25Z
date_with_milliseconds: 2023-01-08T16:18:25.213Z
date_with_microseconds: 2023-01-08T16:18:25.718800Z

Out:

date: 2023-01-08T16:18:25+00:00
date_with_milliseconds: 2023-01-08T16:18:25+00:00
date_with_microseconds: 2023-01-08T16:18:25+00:00

Suggested

In:

date: 2023-01-08T16:18:25Z
date_with_milliseconds: 2023-01-08T16:18:25.213Z
date_with_microseconds: 2023-01-08T16:18:25.718800Z

Out:

date: 2023-01-08T16:18:25+00:00
date_with_milliseconds: 2023-01-08T16:18:25.213+00:00
date_with_microseconds: 2023-01-08T16:18:25.718800+00:00

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