aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/time.rb
Commit message (Collapse)AuthorAgeFilesLines
* Don't allow `where` with invalid value matches to nil valuesRyuta Kamizono2019-02-181-4/+0
| | | | | | | | | That is considered as silently leaking information. If type casting doesn't return any actual value, it should not be matched to any record. Fixes #33624. Closes #33946.
* Extract duplicated `serialize` methods into helpersRyuta Kamizono2019-02-181-0/+4
| | | | | | | | Since `serialize` is passed user input args (from `where`, schema default, etc), a helper should provide `serialize` if the helper also provide `cast`. Related #32624, 34cc301, a741208.
* Fix type cast with values hash for Date typeRyuta Kamizono2019-02-181-0/+1
| | | | | | | | `value_from_multiparameter_assignment` defined by `AcceptsMultiparameterTime` helper requires `default_timezone` method which is defined at `TimeValue` helper. Since `Date` type doesn't include `TimeValue`, I've extracted `Timezone` helper to be shared by `Date`, `DateTime`, and `Time` types.
* Fix year value when casting a multiparameter time hashAndrew White2019-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | When assigning a hash to a time attribute that's missing a year component (e.g. a `time_select` with `:ignore_date` set to `true`) then the year defaults to 1970 instead of the expected 2000. This results in the attribute changing as a result of the save. Before: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 1970-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC After: event = Event.new(start_time: { 4 => 20, 5 => 30 }) event.start_time # => 2000-01-01 20:30:00 UTC event.save event.reload event.start_time # => 2000-01-01 20:30:00 UTC
* Fix user_input_in_time_zone to coerce non valid string into nilAnnie-Claude Côté2018-05-161-0/+2
| | | | Before it was coercing an invalid string into "2000-01-01 00:00:00".
* Normalize date component when writing to time columnsAndrew White2018-03-111-5/+1
| | | | | | | | | | | | | | | For legacy reasons Rails stores time columns on sqlite as full timestamp strings. However because the date component wasn't being normalized this meant that when they were read back they were being prefixed with 2001-01-01 by ActiveModel::Type::Time. This had a twofold result - first it meant that the fast code path wasn't being used because the string was invalid and second it was corrupting the second fractional component being read by the Date._parse code path. Fix this by a combination of normalizing the timestamps on writing and also changing Active Model to be more lenient when detecting whether a string starts with a date component before creating the dummy time value for parsing.
* Apply time column precision on assignmentAndrew White2018-03-111-1/+1
| | | | | | | In #20317, datetime columns had their precision applied on assignment but that behaviour wasn't applied to time columns - this commit fixes that. Fixes #30301.
* Use frozen string literal in activemodel/Kir Shatrov2017-07-161-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-15/+15
|
* applies new string literal convention in activemodel/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* systematic revision of =~ usage in AMoXavier Noria2016-07-241-1/+1
|
* Take UTC offset into account when assigning string value to time attribute.Andrey Novikov2016-01-051-1/+1
|
* Avoid dummy_time_value to add "2000-01-01" twiceYasuo Honda2015-11-301-1/+5
|
* Move ActiveRecord::Type to ActiveModelKir Shatrov2015-09-211-0/+42
The first step of bringing typecasting to ActiveModel