Page 1 of 1
DateUtc
Posted: Mon Apr 03, 2023 1:02 am
by idle
Get UTC time
linux OSX support added Infratec
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
CompilerIf #PB_Compiler_32Bit
ImportC ""
DateUTC.q(t=0) As "_time"
EndImport
CompilerElse
ImportC ""
DateUTC.q(t=0) As "time"
EndImport
CompilerEndIf
CompilerCase #PB_OS_Linux
Procedure.q DateUTC()
ProcedureReturn time_(#Null)
EndProcedure
CompilerCase #PB_OS_MacOS
ImportC ""
CFAbsoluteTimeGetCurrent.d()
EndImport
Procedure.q DateUTC()
ProcedureReturn CFAbsoluteTimeGetCurrent() + Date(2001, 1, 1, 0, 0, 0)
EndProcedure
CompilerEndSelect
CompilerIf #PB_Compiler_IsMainFile
Debug "UTC" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", DateUTC())
Debug "LOCAL" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", Date())
CompilerEndIf
we just came out of daylight savings
UTC 03/04/2023 02:52:43
LOCAL 03/04/2023 14:52:43
Re: DateUtc
Posted: Mon Apr 03, 2023 3:09 am
by Lunasole
Nice. But seems didn't work with x86 compilers on Windows (throws unresolved externals for some reason), only x64.
At least in my case.
Re: DateUtc
Posted: Mon Apr 03, 2023 3:36 am
by Thunder93
Same.
Lunasole wrote: Mon Apr 03, 2023 3:09 am
Nice. But seems didn't work with x86 compilers on Windows (throws unresolved externals for some reason), only x64.
At least in my case.
Re: DateUtc
Posted: Mon Apr 03, 2023 3:48 am
by idle
Lunasole wrote: Mon Apr 03, 2023 3:09 am
Nice. But seems didn't work with x86 compilers on Windows (throws unresolved externals for some reason), only x64.
At least in my case.
fixed
Re: DateUtc
Posted: Mon Apr 03, 2023 7:25 am
by infratec
Extended to be crossplatform:
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
EnableExplicit
CompilerEndIf
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
CompilerIf #PB_Compiler_32Bit
ImportC ""
Date_UTC(t=0) As "_time"
EndImport
CompilerElse
ImportC ""
Date_UTC(t=0) As "time"
EndImport
CompilerEndIf
Procedure.q DateUTC()
ProcedureReturn Date_UTC()
EndProcedure
CompilerCase #PB_OS_Linux
Procedure.q DateUTC()
ProcedureReturn time_(#Null)
EndProcedure
CompilerCase #PB_OS_MacOS
ImportC ""
CFAbsoluteTimeGetCurrent.d()
EndImport
Procedure.q DateUTC()
ProcedureReturn CFAbsoluteTimeGetCurrent() + Date(2001, 1, 1, 0, 0, 0)
EndProcedure
CompilerEndSelect
CompilerIf #PB_Compiler_IsMainFile
Debug "UTC" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", DateUTC())
Debug "LOCAL" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", Date())
CompilerEndIf
Re: DateUtc
Posted: Mon Apr 03, 2023 9:52 am
by idle
infratec wrote: Mon Apr 03, 2023 7:25 am
Extended to be crossplatform:
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
EnableExplicit
CompilerEndIf
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
CompilerIf #PB_Compiler_32Bit
ImportC ""
Date_UTC(t=0) As "_time"
EndImport
CompilerElse
ImportC ""
Date_UTC(t=0) As "time"
EndImport
CompilerEndIf
Procedure.q DateUTC()
ProcedureReturn Date_UTC()
EndProcedure
CompilerCase #PB_OS_Linux
Procedure.q DateUTC()
ProcedureReturn time_(#Null)
EndProcedure
CompilerCase #PB_OS_MacOS
ImportC ""
CFAbsoluteTimeGetCurrent.d()
EndImport
Procedure.q DateUTC()
ProcedureReturn CFAbsoluteTimeGetCurrent() + Date(2001, 1, 1, 0, 0, 0)
EndProcedure
CompilerEndSelect
CompilerIf #PB_Compiler_IsMainFile
Debug "UTC" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", DateUTC())
Debug "LOCAL" + #TAB$ + FormatDate("%dd/%mm/%yyyy %hh:%ii:%ss", Date())
CompilerEndIf
Thanks for that
Re: DateUtc
Posted: Mon Apr 24, 2023 10:21 am
by Kwai chang caine
Thanks for sharing this usefull code worked here

Mainly for europeans people, who never do like the others

Government promise stop this history of summer time, but again it's not the case now

Re: DateUtc
Posted: Tue Apr 25, 2023 4:17 pm
by benubi
Very useful for web applications & interfaces!
Kwai chang caine wrote: Mon Apr 24, 2023 10:21 am
Thanks for sharing this usefull code worked here

Mainly for europeans people, who never do like the others

Government promise stop this history of summer time, but again it's not the case now
And that's only the summer time problem. There are also leap seconds now!
And on an other front in my head megabytes are still megabytes and not mibibytes (or how they are called now); my head and my tongue won't articulate mibibyte except when I'm being sarcastic or joking.
And I'm rather sure there are worse things to come in the near future like 'misgendering' technical words. I refuse to imagine the manuals and the lawsuits...

Re: DateUtc
Posted: Tue Apr 25, 2023 8:49 pm
by idle
I was binge watching red dwarf last week so l'm already ahead on the pronouns, I'm just the Cat. Cool Attractive and Tanned,

so if I say, Yo Sheit, I'm meaning youse human whats it's faces, is that OK. Right gotta go meowww Pussies. that should be offensive enough for the pronoun demanding lot.
