Page 1 of 1
GetTimeZoneInformation_
Posted: Sat Apr 22, 2017 3:23 pm
by PowerSoft
Found this piece of code.
But PB is not recognized the function "GetTimeZoneInformation_"
How to used it?
Code: Select all
Result = GetTimeZoneInformation_(@tzi.TIME_ZONE_INFORMATION)
Debug "unterschied zu UTC Zeit = "+Str(Result)
Debug "---------------------------------------"
Debug tzi\bias
Debug tzi\StandardName
Debug tzi\StandardDate
Debug tzi\StandardBias
Debug tzi\DaylightName
Debug tzi\DaylightDate
Debug tzi\DaylightBias
Re: GetTimeZoneInformation_
Posted: Sat Apr 22, 2017 4:37 pm
by mk-soft
API:
https://msdn.microsoft.com/de-de/librar ... s.85).aspx
Update
Code: Select all
Procedure.s GetTimeString(*Systemtime)
Protected dTime.s = Space(64)
Protected sTime.s = Space(64)
Protected r1, r2, result.s
r1 = GetDateFormat_(#LOCALE_USER_DEFAULT, #Null, *Systemtime, #Null, @dTime, 64)
r2 = GetTimeFormat_(#LOCALE_USER_DEFAULT, #TIME_FORCE24HOURFORMAT, *Systemtime, #Null, @sTime, 64)
If r1
result = dTime
EndIf
If r1 And r2
result + " "
EndIf
If r2
result + stime
EndIf
ProcedureReturn result
EndProcedure
GetSystemTime_(time.systemtime)
Debug "Systemtime: " + GetTimeString(time)
GetLocalTime_(time.systemtime)
Debug "Localtime: " + GetTimeString(time)
Result = GetTimeZoneInformation_(@tzi.TIME_ZONE_INFORMATION)
Debug "Result: "+ Result
Debug "---------------------------------------"
Debug "Bias: " + tzi\bias
Debug "Name: " + PeekS(@tzi\StandardName)
Debug "StandardDate: " + GetTimeString(tzi\StandardDate)
Debug "StandardBias: " + tzi\StandardBias
Debug "DaylightName: " + PeekS(@tzi\DaylightName)
Debug "DaylightDate: " + GetTimeString(tzi\DaylightDate)
Debug "DaylightBias: " + tzi\DaylightBias
__________________________________________________
URL tags added
27.04.2017
RSBasic
Re: GetTimeZoneInformation_
Posted: Sun Apr 23, 2017 1:59 pm
by PowerSoft
mk-soft wrote:API:
https://msdn.microsoft.com/de-de/librar ... s.85).aspx
Update
Code: Select all
Procedure.s GetTimeString(*Systemtime)
Protected dTime.s = Space(64)
Protected sTime.s = Space(64)
Protected r1, r2, result.s
r1 = GetDateFormat_(#LOCALE_USER_DEFAULT, #Null, *Systemtime, #Null, @dTime, 64)
r2 = GetTimeFormat_(#LOCALE_USER_DEFAULT, #TIME_FORCE24HOURFORMAT, *Systemtime, #Null, @sTime, 64)
If r1
result = dTime
EndIf
If r1 And r2
result + " "
EndIf
If r2
result + stime
EndIf
ProcedureReturn result
EndProcedure
GetSystemTime_(time.systemtime)
Debug "Systemtime: " + GetTimeString(time)
GetLocalTime_(time.systemtime)
Debug "Localtime: " + GetTimeString(time)
Result = GetTimeZoneInformation_(@tzi.TIME_ZONE_INFORMATION)
Debug "Result: "+ Result
Debug "---------------------------------------"
Debug "Bias: " + tzi\bias
Debug "Name: " + PeekS(@tzi\StandardName)
Debug "StandardDate: " + GetTimeString(tzi\StandardDate)
Debug "StandardBias: " + tzi\StandardBias
Debug "DaylightName: " + PeekS(@tzi\DaylightName)
Debug "DaylightDate: " + GetTimeString(tzi\DaylightDate)
Debug "DaylightBias: " + tzi\DaylightBias
When compiling this code got an error at:
GetDateFormat_(#LOCALE_USER_DEFAULT, #Null, *Systemtime, #Null, @dTime, 64)
Line 5: GetDateFormat_() is not a function, array, list, map or macro.
How to get this running?
Re: GetTimeZoneInformation_
Posted: Sun Apr 23, 2017 2:06 pm
by mk-soft
It´s all only with Window-OS
I don´t know it on MacOS
Re: GetTimeZoneInformation_
Posted: Sun Apr 23, 2017 8:15 pm
by Shardik
Did you already try whether my
MacOS example may help you?
Re: GetTimeZoneInformation_
Posted: Mon Apr 24, 2017 2:57 pm
by PowerSoft
Shardik wrote:Did you already try whether my
MacOS example may help you?
This is perfect, just what I need for my program
Re: GetTimeZoneInformation_
Posted: Thu Apr 27, 2017 10:11 am
by PowerSoft
Thanks again for this routine. It is very useful for me.
Is it posible to extract only the value 7200 from the message, this is the offset I need from UTC.
Outcomming:
Daylight saving is activated.
Time offset = 60 minutes
Time zone description: Europe/Amsterdam (CEST) offset 7200 (Daylight)
Next daylight saving transition: 2017-10-29 01:00:00
Re: GetTimeZoneInformation_
Posted: Fri Apr 28, 2017 8:41 pm
by Shardik
PowerSoft wrote:Is it posible to extract only the value 7200 from the message, this is the offset I need from UTC.
Code: Select all
Define TimeZoneDescription.S
Define TimeZoneObject.I
TimeZoneObject = CocoaMessage(0, 0, "NSTimeZone systemTimeZone")
TimeZoneDescription = PeekS(CocoaMessage(0, CocoaMessage(0,
TimeZoneObject, "description"), "UTF8String"), -1, #PB_UTF8)
MessageRequester("Offset", StringField(TimeZoneDescription, 4, " "))
Re: GetTimeZoneInformation_
Posted: Sat Apr 29, 2017 9:38 am
by PowerSoft
Thanks just what I needed

Re: GetTimeZoneInformation_
Posted: Sat Apr 29, 2017 11:27 am
by wilbert
Another option would be to use
secondsFromGMT
Code: Select all
Offset = CocoaMessage(0, CocoaMessage(0, 0, "NSTimeZone systemTimeZone"), "secondsFromGMT")
Debug Offset