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