Method: NetSuite::Utilities#normalize_datetime_to_netsuite

Defined in:
lib/netsuite/utilities.rb

#normalize_datetime_to_netsuite(datetime) ⇒ Object

use when sending times to NS



128
129
130
131
132
133
134
135
136
# File 'lib/netsuite/utilities.rb', line 128

def normalize_datetime_to_netsuite(datetime)
  # normalize the time to UCT0
  # add 6 hours (21600 seconds) of padding (CST offset)
  # to force the same time to be displayed in the NS UI

  is_dst = Time.parse(datetime.to_s).dst?

  datetime.new_offset(0) + datetime.offset + Rational(is_dst ? 5 : 6, 24)
end