LB Booster
« Coordinated Universal Time (UTC) »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:37am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Coordinated Universal Time (UTC)  (Read 634 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Coordinated Universal Time (UTC)
« Thread started on: Apr 4th, 2016, 9:33pm »

There is a thread at the Liberty BASIC Community Forum asking how to get the current UTC time. This is quite straightforward using the Windows API, but for some reason nobody seems to have posted the code to do it. Instead various complicated or non-working solutions have been offered.

For the record, here is a simple example of how to print the UTC time in LB or LBB:

Code:
    struct st, wYear as word, wMonth as word, wDayOfWeek as word, _ 
        wDay as word, wHour as word, wMinute as word, wSecond as word, _ 
        wMilliseconds as word
        
    calldll #kernel32, "GetSystemTime", st as struct, ret as long
    
    print "The current time (UTC) is "; dig2$(st.wHour.struct); ":"; _
        dig2$(st.wMinute.struct); ":"; dig2$(st.wSecond.struct)
    end
    
function dig2$(n)
    dig2$ = right$("0" + str$(n), 2)
end function 

Richard.
User IP Logged

cocos
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 1
xx Re: Coordinated Universal Time (UTC)
« Reply #1 on: Apr 6th, 2016, 2:10pm »

Hi Richard,

your program works perfect - I have already integrated it into my program.

Thank you very much!
daniel

P.S. Shall I post it on the other forum as well to have a closed loop or do you prefer not to?
« Last Edit: Apr 6th, 2016, 2:13pm by cocos » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Coordinated Universal Time (UTC)
« Reply #2 on: Apr 6th, 2016, 7:05pm »

on Apr 6th, 2016, 2:10pm, cocos wrote:
Shall I post it on the other forum as well to have a closed loop or do you prefer not to?

It's entirely up to you. I can't post it there myself, but any code I publish is of course free for all to use.

If the code is in any way 'original' an acknowledgement would be appreciated, but in this case it's nothing more than a trivial call to an API function.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls