Module: Intacct::Utils
- Defined in:
- lib/intacct/utils.rb
Constant Summary collapse
- YEAR_FORMAT =
"%Y".freeze
- MONTH_FORMAT =
"%m".freeze
- DAY_FORMAT =
"%d".freeze
- DATE_FORMAT =
"#{MONTH_FORMAT}/#{DAY_FORMAT}/#{YEAR_FORMAT}".freeze
- DATETIME_FORMAT =
"#{MONTH_FORMAT}/#{DAY_FORMAT}/#{YEAR_FORMAT} %H:%M:%S".freeze
Class Method Summary collapse
- .format_date(date) ⇒ Object
- .format_datetime(datetime) ⇒ Object
- .format_day(date) ⇒ Object
- .format_month(date) ⇒ Object
- .format_year(date) ⇒ Object
- .parse_date(date) ⇒ Object
- .parse_datetime(datetime) ⇒ Object
Class Method Details
.format_date(date) ⇒ Object
9 10 11 |
# File 'lib/intacct/utils.rb', line 9 def self.format_date(date) date&.strftime(DATE_FORMAT) end |
.format_datetime(datetime) ⇒ Object
13 14 15 |
# File 'lib/intacct/utils.rb', line 13 def self.format_datetime(datetime) datetime&.strftime(DATETIME_FORMAT) end |
.format_day(date) ⇒ Object
25 26 27 |
# File 'lib/intacct/utils.rb', line 25 def self.format_day(date) date&.strftime(DAY_FORMAT) end |
.format_month(date) ⇒ Object
21 22 23 |
# File 'lib/intacct/utils.rb', line 21 def self.format_month(date) date&.strftime(MONTH_FORMAT) end |
.format_year(date) ⇒ Object
17 18 19 |
# File 'lib/intacct/utils.rb', line 17 def self.format_year(date) date&.strftime(YEAR_FORMAT) end |
.parse_date(date) ⇒ Object
29 30 31 32 33 |
# File 'lib/intacct/utils.rb', line 29 def self.parse_date(date) return nil if date.nil? Date.strptime(date, DATE_FORMAT) end |
.parse_datetime(datetime) ⇒ Object
35 36 37 38 39 |
# File 'lib/intacct/utils.rb', line 35 def self.parse_datetime(datetime) return nil if datetime.nil? DateTime.strptime(datetime, DATETIME_FORMAT) end |