SplitDateTime
A simple gem that allows you to split a DateTime field into a Date and a Time field for separate processing.
Installation
Add this line to your application's Gemfile:
gem 'split_date_time'
And then execute:
$ bundle
Or install it yourself as:
$ gem install split_date_time
Usage
In your ActiveRecord model:
split_date_time field: 'created_at', prefix: 'created'
field (required): The table column you'd like to split.
prefix (optional): A custom prefix to use.
date_format (optional): A custom date format to use.
time_format (optional): A custom time format to use.
The above would generate the following methods:
created_date
created_date=
created_time
created_time=
You'll then be able to use these as you would any other ActiveRecord attribute. The fields will be concatenated and stored as a DateTime when you save the model.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request