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 pointer conversion utilities to transform int64 to time.Time #1433

Merged
merged 3 commits into from
Aug 1, 2017

Conversation

TylerBrock
Copy link
Contributor

@TylerBrock TylerBrock commented Jul 31, 2017

See: #1432 for discussion around adding this feature.

Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting this work. I think this tool would be helpful. Before accepting it I think we should clarify its functionality especially in the seconds and millisecond cases.

@@ -311,6 +311,15 @@ func TimeValue(v *time.Time) time.Time {
return time.Time{}
}

// Int64TimeValue converts an int64 pointer to a time.Time value or
// time.Time{} if the pointer is nil.
func Int64TimeValue(v *int64) time.Time {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful for this to specify the resolution the int64is expected to be. In this case it looks to be millisecond -> second. Is this correct?

Alternatively dropping the Int64 part all together and just SecondsTimeValue and MillisecondTimeValue with int64 input param. Bit more verbose, but clear on the expectations.

Copy link
Contributor Author

@TylerBrock TylerBrock Jul 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach could be to extract the highest time resolution possible (millis) and keep the function name Int64TimeValue. Rounding the output to seconds feels like something that the SDK should not be directly responsible for. Thoughts? I'm open to either approach as I'm not sure which follows convention more closely here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since i don't think there is any requirement required for services to return a specific resolution of time when used in number format I think having a set expectation would be the best approach.

Milliseconds would provide the most general usage. The downside to this would be that i think it would defeat the purpose of this utility for second based int64 fields as the user would need to dereference the *int64 value shift for milliseconds, and grab the pointer again before using the utility. This is where the idea of resolution specific methods came from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood and agreed. Let me get that up for us.

See: aws#1432 for discussion around adding this feature.
@TylerBrock TylerBrock changed the title Add pointer conversion utility for int64 to time.Time Add pointer conversion utilities to transform int64 to time.Time Jul 31, 2017
@jasdel
Copy link
Contributor

jasdel commented Jul 31, 2017

Thanks for updating the names. Would you mind adding a test case for each helper utility to the convert_types_test.go file.

In addition one minor tweak to the wording of the functions' doc comment would be to include that seconds and milliseconds are since Epoch. Just to make sure thats clear.

Copy link
Contributor

@jasdel jasdel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these updates.

@jasdel jasdel merged commit 71a6866 into aws:master Aug 1, 2017
jasdel added a commit that referenced this pull request Aug 1, 2017
@awstools awstools mentioned this pull request Aug 9, 2017
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.

2 participants