Method: XeroRuby::Accounting::HistoryRecords#parse_date
- Defined in:
- lib/xero-ruby/models/accounting/history_records.rb
#parse_date(datestring) ⇒ Object
211 212 213 214 215 216 217 218 219 220 |
# File 'lib/xero-ruby/models/accounting/history_records.rb', line 211 def parse_date(datestring) if datestring.include?('Date') date_pattern = /\/Date\((-?\d+)(\+\d+)?\)\// original, date, timezone = *date_pattern.match(datestring) date = (date.to_i / 1000) Time.at(date).utc.strftime('%Y-%m-%dT%H:%M:%S%z').to_s else # handle date 'types' for small subset of payroll API's Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s end end |