datify¶ ↑
Datify is a rubygem to convert a string storing a date or a time in a proper Time ruby object. Imagine you have a text file containing a list of string formatted this way ‘day-month-year’ and you want to have fulle featured Time object now you can with datify.
NEWS From the version 0.50 and beyond, you don’t have to call internal Datify::Engine methods anymore, but eventually you may want to use two new methods datify has added to String class.
If you require the datify gem, your strings will acquire:
is_time? - a boolean checking out if the string is a good datetime to_time - the core method returning a Time object for the self class
The API now is even easier.
"23-giu-1976".is_time? _~> true_ "23-giu-1976".to_time _1976-06-23 00:00:00 +0200_
Of course you can work in the previous way as well.
require 'datify' my_date = Datify::Engine.new('16-giu-1976') puts my_date.date.to_s
That’s it!
Install¶ ↑
You may want to install datify with the following command:
gem install datify
Contributing to datify¶ ↑
-
Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
-
Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
-
Fork the project
-
Start a feature/bugfix branch
-
Commit and push until you are happy with your contribution
-
Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright¶ ↑
Copyright © 2011 Paolo Perego. See LICENSE.txt for further details.