Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for alternative timestamp formats #273

Merged
merged 2 commits into from
Jan 7, 2018

Conversation

rogpeppe
Copy link
Contributor

@rogpeppe rogpeppe commented Jul 21, 2017

yaml.org describes several alternative formats for timestamps not
covered by the default implementation of time.UnmarshalText(). A subset
of these is covered by this PR - future work can enable full
support for all formats.

Timestamps will only be collected if there is an explicit timestamp
tag (ie, not !!str) or if implicit type detection is enabled.

This PR builds on @anthonybishopric's foundations
(see PR #117).

yaml.org describes several alternative formats for timestamps not
covered by the default implementation of `time.UnmarshalText()`. These
are handled explicitly in this change in resolve.go

Timestamps will only be collected if there is an explicit timestamp
tag (ie, not `!!str`) or if implicit type detection is enabled.
Factor the timestamp parsing into its own function that
can easily be changed later to support the full range of
time stamps and add a quick early check to avoid
going through all the time.Parse calls in this common
path.

Also fix marshaling so that times are still printed unquoted.
@rogpeppe rogpeppe merged commit c4a9fb4 into go-yaml:v2 Jan 7, 2018
rogpeppe added a commit to rogpeppe-contrib/yaml that referenced this pull request Jan 8, 2018
It was accidentally applied to v2 not the devel branch.
rogpeppe added a commit that referenced this pull request Jan 8, 2018
djgilcrease pushed a commit to djgilcrease/yaml that referenced this pull request Mar 14, 2018
It was accidentally applied to v2 not the devel branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant