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

Handle time.Duration in Preparer #358

Closed
arichardet opened this issue Oct 7, 2016 · 3 comments
Closed

Handle time.Duration in Preparer #358

arichardet opened this issue Oct 7, 2016 · 3 comments
Assignees
Milestone

Comments

@arichardet
Copy link
Contributor

At some point, a date in ISO 8601 will need to be accepted for a field for the user module. This may be useful for other modules, so we probably want to handle this in the preparer.

@BrianHicks
Copy link
Contributor

How about this?

type Blah struct {
    Timeout    time.Duration `hcl:"timeout"`
    ExpiryDate time.Time     `hcl:"time"`
}

if the parser hits a time.Duration it will parse it with time.ParseDuration and expose the error (if any) to the user.

If the parser hits a time.Time, it will parse it as "YYYY-MM-DDThh:mm:ssz". If that fails, it will try parsing as "YYYY-MM-DD" and set the time of day to zero and the timezone to the system timezone.

@arichardet
Copy link
Contributor Author

Yes, that seems to make sense.

@BrianHicks BrianHicks added this to the 0.4.0 milestone Oct 20, 2016
@arichardet arichardet self-assigned this Nov 1, 2016
@arichardet arichardet changed the title Preparer handling dates Handle time.Duration in Preparer Nov 10, 2016
@arichardet
Copy link
Contributor Author

Closing this issue for the implementation of time.Duration. Opening issue #490 to handle adding time.Time.

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

No branches or pull requests

2 participants