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

Added time_attr and time marshaler #81

Merged
merged 2 commits into from Jun 7, 2018
Merged

Added time_attr and time marshaler #81

merged 2 commits into from Jun 7, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jun 7, 2018

Description of changes:

RuboCop guidance says to avoid DateTime: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/DateTime
rubocop/rubocop#1952

And additionally, the Ruby docs recommend to use Time:

https://ruby-doc.org/stdlib-2.5.1/libdoc/time/rdoc/Time.html

With DateTime, we're able to save a Time object to DynamoDB but it comes back out as a DateTime. I added a time marshaler and defined a time_attr so that we can store serialized Time objects.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Member

@awood45 awood45 left a comment

Choose a reason for hiding this comment

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

Pretty close, generally happy to take this.

it 'converts Dates to Time' do
expected = Time.parse("2009-02-13 08:00:00 UTC")
input = Date.parse("2009-02-13")
expect(@marshaler.type_cast(input)).to eq(expected)
Copy link
Member

Choose a reason for hiding this comment

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

This test will only work if the computer running it is in the Pacific Daylight Timezone or equivalent. Needs to be a system time zone agnostic test.

@ghost
Copy link
Author

ghost commented Jun 7, 2018

As discussed in Chime, I've removed the Date -> Time test as it's a pretty silly thing to do anyway. Anyone trying to save a Date as a Time attribute is just asking for it, and when they retrieve that record they can expect it to be a Time object anyway.

@awood45 awood45 merged commit 29de47f into aws:master Jun 7, 2018
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