0.0
No commit activity in last 3 years
No release in over 3 years
Allows DateTime fields to be split into a Date field and a Time field.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

SplitDateTime

Code Climate Code Climate

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request