1. Roy Bungert
  2. PowerBuilder
  3. Friday, 5 July 2019 10:52 AM UTC

Hello,

ok, it's not a big issue to develop it my ourself, but is there any build-in functionality to change timestamps to UTC and vice versa?

Or any plans to implement that?

Regards

Roy

 

Who is viewing this page
Roy Bungert Accepted Answer Pending Moderation
  1. Monday, 8 July 2019 06:59 AM UTC
  2. PowerBuilder
  3. # 1

Thank you, that helps a lot. I will try it.

 

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Monday, 8 July 2019 05:25 AM UTC
  2. PowerBuilder
  3. # 2

Hi,

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

 

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Saturday, 6 July 2019 12:45 PM UTC
  2. PowerBuilder
  3. # 3

Hi Roy, I haven't heard of specific UTC functionality.

Windows has API functions to obtain local time or UTC time. So does most if not all major databases.

Denmark being tiny in area (approx. 16'500 mi²) I though all timestamps were comparable - until Greenland timestamps (3 time zones) and Faroe Islands (1 time zone) hit me. I solved the issue on client by calling on client and GetUtcDate( ) on server - compare timestamps and thereby know time offset for current user.

Maybe someone already wrote an NVO they want to share?

HTH /Michael

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 5 July 2019 15:35 PM UTC
  2. PowerBuilder
  3. # 4

Hi Roy;

  I have not heard of any new UTC feature support planned for PB from Appeon Engineering for the PB2019Rx series of releases. If you like, you can open a support ticket as an enhancement request for this feature.

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.