How to get the GMT offset from current time zone

Hi

I have an app which is used by people all over the world. In the app, there are fields which hold dates and times from the local time zone of the user. I'd like to create sister fields to these which contains the GMT time. I can, of course, create a table with the time offsets and do a NotesDateTime.AjustHour. But I was hoping there was some LotusScript call which would make this easier.

thanks

clem

Maybe the GMTTime (NotesDateTime - LotusScript)?

https://help.hcltechsw.com/dom_designer/9.0.1/appdev/H_GMTTIME_PROPERTY.html

Please note that the GMTTime property returns a formatted string, not a datetime varian, so that could pose a problem, since different formattings exist. You should use LsGMTTime property.

Also, to set the GMT fields, you should use a NotesDateTime object with the the zone set to GMT to set them. Otherwise you still get dateTime fields with the zone set to the local zone and not GMT. Since the LsGMTTime property is readonly, you cannot set it and expext a GMTTime. You should create or initialize a NotesDateTime object, set its TimeZone property to 0 (=GMT), and then set the LSLocaltime property to the value you got from LsGMTTime. And then check results, I have not tested this myself ;-)

Also, for display, a Date/Time field has Time display settings available. In those, you can specify to always display the time zone, which you can show the time calways converted to the local zone, always with the time zone, or display the zone only if not local.

I think you should be able to concoct a solution from these ingredients.

Hi Lars,
Thanks for the suggestion. It gave me a few things to try.
My ultimate goal is to determine the time between 2 events : issue Open date/time and issue Closed date/time. The problem is that the Open date/time is in US Eastern time zone whereas the Closed date/time could be in, say, Australia. I want to know the time difference between the Closed and Open, but if I do a NotesDateTime.TimeDifference without taking into account the time zone, the value will be incorrect. So I had the idea to convert both Open and Closed to GMT and THEN do the TimeDifference.

I did

Set createDateGMT = New NotesDateTime( createDate.lsGMTTime )
However, this made 'createDateGMT' with the correct GMT time but it set the time zone to US Eastern Time (where I am). I don't see a way to set the time zone for this new GMT NotesDateTime variable. It might not matter if I'm just doing the time difference on the fly but it would be nice to keep that date/time in GMT to refer to it later w/o having to recalculate it.

thanks again

Clem

Hi Lars,
Thanks for the suggestion. It gave me a few things to try.
My ultimate goal is to determine the time between 2 events : issue Open date/time and issue Closed date/time. The problem is that the Open date/time is in US Eastern time zone whereas the Closed date/time could be in, say, Australia. I want to know the time difference between the Closed and Open, but if I do a NotesDateTime.TimeDifference, the value will be incorrect. So I had the idea to convert both Open and Closed to GMT and THEN do the TimeDifference.

I did

Set createDateGMT = New NotesDateTime( createDate.lsGMTTime )
However, this made 'createDateGMT' into the right GMT time but put it in US Eastern time zone. I can't find a way to set the timezone to GMT. But maybe it would be ok if they both have the same date/time so the subtraction would work. I'll play with that.

thanks

clem

NotesDateTime.ConvertToZone: https://help.hcl-software.com/dom_designer/9.0.1/appdev/H_CONVERTTOZONE_METHOD.html

When in doubt, open the manual. There are lots of goodies in the Notesxxx objects. I have learnt a lot by just perusing the LotusScript Classes A-Z

useDST = True ' needs checking. The description in the documentation is not airtight. If they mena that the new time zone normally foollows DST, then it should be always True. Verification avoids embaressment.

Const TIMEZONE_GMT = 0 ' Time zone 0 = GMT. Often the TimeZone value is the same as the number of hours the Zone differs from GMT. Some zones have non-integer difference with GMT

Set createDateGMT = New NotesDateTime( createDate.lsGMTTime )

Call createDateGMT.ConvertToTimeZone( TIMEZONE_GMT, useDST )

Hi Lars

I normally look through the documentation before I ever post but I have to admit that I missed ConvertToTimeZone. After you mentioned it, I did try using but it gave the same result as what I had done above:

Set createDateGMT = New NotesDateTime( createDate.lsGMTTime )

However, manually converting several date/time values of the create & closed events to GMT, I came to realize that NotesDateTime.TimeDifference already seems to take care of the time zones! I don't actually have to create GMT fields so I can then take the difference. I just assumed, after looking at the date/times in the fields, that the subtraction would be off.

Thanks for looking into this. I appreciate. Sorry for the trouble, tho.

Clem