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

time: ParseDuration does not accept types above hour on Windows #23654

Closed
thumbsized opened this issue Feb 1, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@thumbsized
Copy link

commented Feb 1, 2018

I have a duration flag and when I use any larger type than hour, it will fail.
Looking at the

var durationRE = regexp.MustCompile("^([0-9]+)(y|w|d|h|m|s|ms)$")

it should support days, weeks and years. But it will fail. I tried even 30d0h but even that won't work.

I am running Windows 10x64 and Go 1.9.2

@bontibon

This comment has been minimized.

Copy link
Contributor

commented Feb 1, 2018

I'm not sure where you're getting the durationRE value from, but time.ParseDuration does not support any unit larger than hours. This is documented:

There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions.

@mvdan

This comment has been minimized.

Copy link
Member

commented Feb 1, 2018

Like @bontibon said, this is working as expected. I also don't know where you got that line from - it's never been in the Go tree.

@mvdan mvdan closed this Feb 1, 2018

@thumbsized

This comment has been minimized.

Copy link
Author

commented Feb 1, 2018

duration

@bontibon

This comment has been minimized.

Copy link
Contributor

commented Feb 1, 2018

@ivanjaros That isn't from the Go standard library. Open an issue with the 3rd-party library that you're using.

@mikioh mikioh changed the title time.ParseDuration does not accept types above hour on Windows time: ParseDuration does not accept types above hour on Windows Feb 1, 2018

@thumbsized

This comment has been minimized.

Copy link
Author

commented Feb 2, 2018

Aaah, I see. I just followed the Flag library for the duration variable and didn't notice there are multiple implementations of ParseDuration. In the core I see that only up to hour values are supported.

@golang golang locked and limited conversation to collaborators Feb 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.