323
324
325
326
327
328
329
330
331
332
333
334
|
# File 'lib/xero-ruby/models/accounting/phone.rb', line 323
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
elsif /(\d\d\d\d)-(\d\d)/.match(datestring) Time.parse(datestring + '-01').strftime('%Y-%m-%dT%H:%M:%S').to_s
else Time.parse(datestring).strftime('%Y-%m-%dT%H:%M:%S').to_s
end
end
|