https://netsuiteprofessionals.com logo
#suitetalkapi
Title
# suitetalkapi
a

Alex Pilgun

04/18/2022, 10:44 PM
Hi, I'm trying to wrap my head around daylight savings in the Netsuite and I just can't. The task looks soo simple - I just want to get dates as they are shown in the Netsuite UI (but of course they are datetimes under the hood and I can't set pacific timezone for API user for specific reason). I have seen this wonderful Help Center article but I still can't figure it out. Quote #1 from that article:
When getting the date field through SOAP web services, your preferred time zone influences the resulting datetime. Midnight in the user's time zone of the stored date (which is also displayed in the UI) is converted to Pacific Standard Time (PST) or Pacific Daylight Time (PDT), and sent to the SOAP web services user.
Ok, that was easy (before daylight savings started): • API user's timezone is GMT. • Netsuite UI date = 2022-04-18 • Netsuite SOAP date value = 2022-04-17T160000.000-08:00 Totally makes sense, since this is converted to 2022-04-18T000000.000Z and I get the expected date part of 2022-04-18. Quote #2 from the same article:
The NetSuite time zone settings in Home > Set Preferences are based on standard time settings. You must keep in mind the required adjustments during daylight saving time in the year. For example, if your time zone setting in shows (GMT-06:00) Central Time (US & Canada), this is perceived as -05:00 in SOAP web services context during daylight saving time, but -06:00 in standard time.
Therefore, if you send a SOAP web services request indicating CST (-6) when daylight saving time is in effect, as in the following example: <tranDate xsi:type="xsd:dateTime">2015-04-13T222626.923-06:00</tranDate>, the datetime field on the target record is set using CDT (-5) i.e.232626.923 instead of the intended 222626.923.
Important: If the time is close to midnight, the date may change to the next day after the conversion.
With the same API user with GMT timezone and same Netsuite UI date = 2022-04-18 I now receive in SOAP 2022-04-17T160000.000*-07:00* instead of -08:00. By taking the date part this actually converts to 2022-04-1*7* instead of expected 2022-04-1*8* in GMT. Just..why does this happen? And how Netsuite suggests to work with this? Does the bold sentences in quote #2 imply that my client code needs to remember when daylight savings are in effect in my timezone and to account for that 1 hour difference somehow? Am I missing something?
b

battk

04/18/2022, 11:07 PM
your question is partially the difference between a timezone and an offset
and how netsuite treats Date fields
offsets represents the difference between a date time string and GMT time
importantly, they arent actually affected by daylight savings, -05:00 is always a 5 hour difference between it and gmt time
timezones do include information about daylight savings
now for the date part in netsuite
dates are represented as midnight in whatever timezone is set in the ui
so 2022-04-18 for GMT is actually 2022-04-18T000000.000+00:00
2022-04-18 for Pacific time is actually 2022-04-18T000000.000-07:00
which are actually different date times, but thats just how netsuite treats dates
and now onto your part of the question, netsuite's (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London timezone is actually Europe/London
which actually does observe daylight saving time
so 2022-04-18 for Europe/London is actually 2022-04-18T000000.000+01:00
(GMT) Casablanca is the actual GMT
m

Mike Robbins

04/19/2022, 12:47 PM
That's very useful information, Thanks. The complexities of working with date/times and timezones has always fascinated me.
a

Alex Pilgun

04/19/2022, 10:49 PM
Thanks so much @battk! This clarified everything. Now I understand why we need so much timezones with the similar offset. Just 2 cents - it looks like in the Netsuite's timezone selector (GMT) Monrovia, Reykjavik is the true GMT timezone for the whole year (with zero offset) because (GMT) Casablanca has indeed 0 offset for DST but +1 offset for STD. Not the best source but still: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
b

battk

04/19/2022, 11:05 PM
format.Timezone maps olson timezones to netsuite timezones
both (GMT) Casablanca and (GMT) Monrovia, Reykjavik have 0 offsets, but Casablanca is actually using the GMT identifier