1. David Peace (Powersoft)
  2. PowerServer
  3. Thursday, 29 August 2024 13:01 PM UTC

Hi Guys

I've just notice that Powerserver is returning session info that is 1 hour out. It looks like it's recording date times in UTC rather than local time, is that correct? If so is there a way to configure Powerserver to log using Local time on the server?

If not then I guess I'll just have to adjust the times for UTC to GMT to reflect the actual time?

Any thoughts welcomed.

 

Thanks

David

Accepted Answer
mike S Accepted Answer Pending Moderation
  1. Thursday, 29 August 2024 14:06 PM UTC
  2. PowerServer
  3. # Permalink

"configure Powerserver to log using Local time"

" Powerserver is returning session info"

 

are you talking about the api returning session info, or logging events in the server's event log?  I assume the hosting system is responsible for how the time is logged/displayed?

 

IMO, the api returning time in UTC makes sense. At least for me, using powerserver means multiple time zones so UTC/GMT makes sense.  Plus , it is standard for webapis to return time in UTC.

 

just wish we had native PB functionality to convert UTC and local because of things like this.  Multiple functions would be needed: UTCToLocal and converttotimezone. 

and then, maybe one day in the future, support this stuff in datawindows.  in the future when we have flying cars and robots to do the cleaning.  which means appeon would need to start on this right away.

Comment
  1. David Peace (Powersoft)
  2. Thursday, 29 August 2024 14:16 PM UTC
Yes, sorry for not being totally clear. The API is returning times in UTC, and yes you are right that some UTC to Localtime functions would be nice. I just wondered if there was some configuration that I had missed.



Here is some code that Rene provided:



here is an example for converting UTC to local time using Windows API.



(For conversion to UTC see function TzSpecificLocalTimeToSystemTime)







// external functions



protected Function boolean GetTimeZoneInformationForYear &

(uint year, &

char tz, &

ref os_time_zone_information lpTimeZoneInformation) Library "kernel32"



protected Function boolean SystemTimeToTzSpecificLocalTime &

(os_time_zone_information lpTimeZone, &

os_systemtime lpUniversalTime, &

ref os_systemtime lpLocalTime ) Library "kernel32"







// structures



type os_systemtime from structure

unsignedinteger wyear

unsignedinteger wmonth

unsignedinteger wdayofweek

unsignedinteger wday

unsignedinteger whour

unsignedinteger wminute

unsignedinteger wsecond

unsignedinteger wmilliseconds

end type



type os_time_zone_information from structure

long bias

integer standardname[32]

os_systemtime standarddate

long standardbias

integer daylightname[32]

os_systemtime daylightdate

long daylightbias

end type







// function datetime of_utc2local (datetime adtm_utc)



datetime ldtm_local

os_time_zone_information lstr_tzi

os_systemtime lstr_utc

os_systemtime lstr_local

char lc_c

boolean lb_rc





SetNull (ldtm_local)



//local time zone

lb_rc = GetTimeZoneInformationForYear (Year(Date(adtm_utc)), lc_c, lstr_tzi)

IF NOT lb_rc THEN return ldtm_local



//PowerBuilder datetime -> SYSTEMTIME (for UTC)

lstr_UTC.wYear = Year(Date(adtm_utc))

lstr_UTC.wMonth = Month(Date(adtm_utc))

lstr_UTC.wDay = Day(Date(adtm_utc))

lstr_UTC.wHour = Hour(Time(adtm_utc))

lstr_UTC.wMinute = Minute(Time(adtm_utc))

lstr_UTC.wSecond = Second(Time(adtm_utc))

lstr_UTC.wMilliseconds = 0



//Convert to local time zone

lb_rc = SystemTimeToTzSpecificLocalTime (lstr_tzi, lstr_UTC, lstr_local)

IF NOT lb_rc THEN return ldtm_local



//Convert SYSTEMTIME to PowerBuilder datetime

ldtm_local = DateTime (Date (lstr_local.wYear, lstr_local.wMonth, lstr_local.wDay), &

Time (lstr_local.wHour, lstr_local.wMinute, lstr_local.wSecond))



return ldtm_local
  1. Helpful 1
There are no comments made yet.


There are replies in this question but you are not allowed to view the replies from this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.