0.0
No commit activity in last 3 years
No release in over 3 years
This gem makes it easy to convert string to date and provides method to create a string version for the attribute
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
= 13.0.1

Runtime

 Project Readme

Build Status

StringifyDate

This gem provides a _string and _string= to date and datetime attributes.

Installation

Add this line to your application's Gemfile:

gem 'stringify_date'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stringify_date

Usage

For example, we create a Product model which has an date validity column and we want to handle it by using a String object instead:

class Product < ActiveRecord::Base
  # the format will be used to format date and datetime as string
  stringify :validity, format: '%d/%m/%Y'

end

Now each Product object will also have attributes called validity_string and validity_string= to use date and datetime as string.

So

product = Product.new validity: Date.new(2001,2,3)

We can use now _string

product.validity_string # => '03/02/2001'

Publishing

Bundle the gem

gem rake build

Push the package

gem push pkg/stringify_date-x.x.x.gem

Contributing

  1. Fork it ( https://github.com/matheusvetor/stringify_date/fork )
  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 a new Pull Request