Just starting out? Need help? Post your questions and find answers here.
PowerSoft
User
Posts: 65 Joined: Sun Aug 16, 2015 2:54 pm
Post
by PowerSoft » Sat Apr 22, 2017 3:23 pm
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
OS X 10.10.5 PB 5.31(x64)
mk-soft
Always Here
Posts: 5335 Joined: Fri May 12, 2006 6:51 pm
Location: Germany
Post
by mk-soft » Sat Apr 22, 2017 4:37 pm
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
PowerSoft
User
Posts: 65 Joined: Sun Aug 16, 2015 2:54 pm
Post
by PowerSoft » Sun Apr 23, 2017 1:59 pm
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?
OS X 10.10.5 PB 5.31(x64)
mk-soft
Always Here
Posts: 5335 Joined: Fri May 12, 2006 6:51 pm
Location: Germany
Post
by mk-soft » Sun Apr 23, 2017 2:06 pm
It´s all only with Window-OS
I don´t know it on MacOS
Shardik
Addict
Posts: 1989 Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany
Post
by Shardik » Sun Apr 23, 2017 8:15 pm
Did you already try whether my
MacOS example may help you?
PowerSoft
User
Posts: 65 Joined: Sun Aug 16, 2015 2:54 pm
Post
by PowerSoft » Mon Apr 24, 2017 2:57 pm
Shardik wrote: Did you already try whether my
MacOS example may help you?
This is perfect, just what I need for my program
OS X 10.10.5 PB 5.31(x64)
PowerSoft
User
Posts: 65 Joined: Sun Aug 16, 2015 2:54 pm
Post
by PowerSoft » Thu Apr 27, 2017 10:11 am
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
OS X 10.10.5 PB 5.31(x64)
Shardik
Addict
Posts: 1989 Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany
Post
by Shardik » Fri Apr 28, 2017 8:41 pm
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, " "))
PowerSoft
User
Posts: 65 Joined: Sun Aug 16, 2015 2:54 pm
Post
by PowerSoft » Sat Apr 29, 2017 9:38 am
Thanks just what I needed
OS X 10.10.5 PB 5.31(x64)
wilbert
PureBasic Expert
Posts: 3870 Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands
Post
by wilbert » Sat Apr 29, 2017 11:27 am
Another option would be to use
secondsFromGMT
Code: Select all
Offset = CocoaMessage(0, CocoaMessage(0, 0, "NSTimeZone systemTimeZone"), "secondsFromGMT")
Debug Offset
Windows (x64)
Raspberry Pi OS (Arm64)