Module: Intacct::Utils
- Defined in:
- lib/intacct/utils.rb
Constant Summary collapse
- YEAR_FORMAT =
"%Y"- MONTH_FORMAT =
"%m"- DAY_FORMAT =
"%d"- 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
11 12 13 |
# File 'lib/intacct/utils.rb', line 11 def self.format_date(date) date&.strftime(DATE_FORMAT) end |
.format_datetime(datetime) ⇒ Object
15 16 17 |
# File 'lib/intacct/utils.rb', line 15 def self.format_datetime(datetime) datetime&.strftime(DATETIME_FORMAT) end |
.format_day(date) ⇒ Object
27 28 29 |
# File 'lib/intacct/utils.rb', line 27 def self.format_day(date) date&.strftime(DAY_FORMAT) end |
.format_month(date) ⇒ Object
23 24 25 |
# File 'lib/intacct/utils.rb', line 23 def self.format_month(date) date&.strftime(MONTH_FORMAT) end |
.format_year(date) ⇒ Object
19 20 21 |
# File 'lib/intacct/utils.rb', line 19 def self.format_year(date) date&.strftime(YEAR_FORMAT) end |
.parse_date(date) ⇒ Object
31 32 33 34 35 |
# File 'lib/intacct/utils.rb', line 31 def self.parse_date(date) return nil if date.nil? Date.strptime(date, DATE_FORMAT) end |
.parse_datetime(datetime) ⇒ Object
37 38 39 40 41 |
# File 'lib/intacct/utils.rb', line 37 def self.parse_datetime(datetime) return nil if datetime.nil? DateTime.strptime(datetime, DATETIME_FORMAT) end |