Class: LocaSMS::Helpers::DateTimeHelper
- Inherits:
-
Object
- Object
- LocaSMS::Helpers::DateTimeHelper
- Defined in:
- lib/locasms/helpers/date_time_helper.rb
Overview
Helper class to handle with time parsing
Class Method Summary collapse
-
.parse(date) ⇒ Object
Parse a value into a time.
-
.split(date) ⇒ Object
Breaks a given date in date and time.
Instance Method Summary collapse
-
#parse(date) ⇒ Object
Parse a value into a time.
-
#split(date) ⇒ Object
Breaks a given date in date and time.
Class Method Details
.parse(date) ⇒ Object
Parse a value into a time
18 19 20 21 22 |
# File 'lib/locasms/helpers/date_time_helper.rb', line 18 def self.parse(date) date = Time.at(date) if date.is_a? Fixnum date = Time.parse(date) if date.is_a? String date = date.to_time if date.respond_to? :to_time end |
.split(date) ⇒ Object
Breaks a given date in date and time
36 37 38 |
# File 'lib/locasms/helpers/date_time_helper.rb', line 36 def self.split(date) parse(date).strftime('%d/%m/%Y %H:%M').split(' ') end |
Instance Method Details
#parse(date) ⇒ Object
Parse a value into a time
52 53 54 |
# File 'lib/locasms/helpers/date_time_helper.rb', line 52 def parse(date) DateTimeHelper.parse date end |
#split(date) ⇒ Object
Breaks a given date in date and time
68 69 70 |
# File 'lib/locasms/helpers/date_time_helper.rb', line 68 def split(date) DateTimeHelper.split date end |