aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/date.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #29651 from Sayanc93/return-correct-dateRyuta Kamizono2019-02-181-1/+1
|\ | | | | | | Return correct date in ActiveModel for time to date conversions
| * Return correct date in ActiveModel for time to date conversionsSayan Chakraborty2017-12-171-1/+13
| | | | | | | | | | | | | | time.to_date conversion happens considering leap years so a conversion of "Day.new({'day(1i)'=>'1', 'day(2i)'=>'1', 'day(3i)'=>'1'})" results in saving the date as Mon, 03 Jan 0001 which might seem weird on the user level, hence falling back to parsing on string level resolves this data mismatch Fixes #28521
* | Extract duplicated `serialize` methods into helpersRyuta Kamizono2019-02-181-4/+0
| | | | | | | | | | | | | | | | 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.
* | PostgreSQL: Allow BC dates like datetime consistentlyRyuta Kamizono2018-02-231-1/+1
|/ | | | | | | | | BC dates are supported by both date and datetime types. https://www.postgresql.org/docs/current/static/datatype-datetime.html Since #1097, new datetime allows year zero as 1 BC, but new date does not. It should be allowed even in new date consistently.
* 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
|
* Use `inspect` in `type_cast_for_schema` for date/time and decimal valuesRyuta Kamizono2016-12-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently dumping defaults on schema is inconsistent. Before: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: '2014-06-05' t.datetime "datetime_with_default", default: '2014-06-05 07:17:04' t.time "time_with_default", default: '2000-01-01 07:17:04' t.decimal "decimal_with_default", default: 1234567890 end ``` After: ```ruby create_table "defaults", force: :cascade do |t| t.string "string_with_default", default: "Hello!" t.date "date_with_default", default: "2014-06-05" t.datetime "datetime_with_default", default: "2014-06-05 07:17:04" t.time "time_with_default", default: "2000-01-01 07:17:04" t.decimal "decimal_with_default", default: "1234567890" end ```
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-25/+25
|
* Fix `Type::Date#serialize` to return a date object correctlyRyuta Kamizono2016-06-161-0/+4
| | | | | | | | Currently `Type::Date#serialize` does not cast a value to a date object. It should be cast to a date object for finding by date column correctly working. Fixes #25354.
* Move ActiveRecord::Type to ActiveModelKir Shatrov2015-09-211-0/+50
The first step of bringing typecasting to ActiveModel