-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
If I store an end_of_year time object in NSUserDefaults, there is a rounding error due to the microseconds that ups it to the beginning of the next year. See below (where $defaults is my NSUserDefaults object):
Time.local(2015, 12, 31, 23, 59, 59, Rational(999999999, 1000))
=> 2015-12-31 23:59:59 -0800
$defaults[:filters_date_to] = Time.local(2015, 12, 31, 23, 59, 59, Rational(999999999, 1000))
=> 2015-12-31 23:59:59 -0800
$defaults[:filters_date_to]
=> 2016-01-01 00:00:00 -0800
motion-support code in question is below. I don't know a safe way to fix this w/o a dirty hacking, so it's more of any FYI to other users for now.
# Returns a new Time representing the end of the day, 23:59:59.999999 (.999999999 in ruby1.9)
def end_of_day
change(
:hour => 23,
:min => 59,
:sec => 59,
:usec => Rational(999999999, 1000)
)
end
Metadata
Metadata
Assignees
Labels
No labels