Skip to content

Splits a DateTime field into separate 'Date' and 'Time' fields.

License

Notifications You must be signed in to change notification settings

ccallebs/split_date_time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Splits a DateTime field into separate 'Date' and 'Time' fields.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages