Module: NetSuite::Utilities
- Defined in:
- lib/netsuite/utilities.rb
Class Method Summary collapse
-
.normalize_datetime_from_netsuite(datetime) ⇒ Object
use when displaying times from a NS record.
-
.normalize_datetime_to_netsuite(datetime) ⇒ Object
use when sending times to NS.
Class Method Details
.normalize_datetime_from_netsuite(datetime) ⇒ Object
use when displaying times from a NS record
25 26 27 28 29 30 31 |
# File 'lib/netsuite/utilities.rb', line 25 def self.normalize_datetime_from_netsuite(datetime) # the code below eliminates the TimeZone offset then shifts the date forward 2 hours (7200 seconds) # this ensures that ActiveRecord is given a UTC0 DateTime with the exact hour that # was displayed in the NS UI (CST time zone), which will result in the correct display on the web side datetime.new_offset(0) + datetime.offset + Rational(2, 24) end |
.normalize_datetime_to_netsuite(datetime) ⇒ Object
use when sending times to NS
14 15 16 17 18 19 20 21 22 |
# File 'lib/netsuite/utilities.rb', line 14 def self.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 |