Re: systemtime

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 18 Sep 2003 22:08:30 -0300 (09/19/03 11:08:30)
, <rml at rubis.trix.net> wrote:

>
> Could anyone please explain to me how to use and for what is this 
> function from win32lib:
>
>
> fecth_systemtime(atom SYSTEMTIME)
>
>
> In the win32lib documentation there's is nothing about it.
>

So about the poor docs, I'll fix that. Anyhow, all this does is return the 
data inside the supplied SYSTEMTIME structure pointer as a formatted 
sequence of values. Namely ...

      {
       Year,
       Month,
       DayOfWeek,
       Day,
       Hour,
       Minute,
       Second,
       Milliseconds
      }

Now the real question is, how does the SYSTEMTIME structure get the right 
values into it? Currently, these values are populated by the MonthCalendar 
control type. In the next release there is also two new functions - 
getSystemTime() which returns the current date/time in UTC and 
getLocalTime() which returns it according to your timezone settings.

If you can't wait for the next release, here are the two new functions...


Firstly though you will need to add these three lines just after the 
win32lib include...

constant
      xGetSystemTime      = registerw32Procedure(kernel32,"GetSystemTime", 
{C_POINTER}),
      xGetLocalTime       = registerw32Procedure(kernel32,"GetLocalTime", 
{C_POINTER})

------------------------
--/topic Utilities
--/func getSystemTime()
--/desc Gets the date and time as UTC (a.k.a. GMT)
--/ret SEQUENCE: The date and time (See below for details)
--This does not need any parameters. The date and time are returned
-- as UTC (Coordinated Universal Time) which is the old Greenwich Mean 
Time.
--
--The return sequence has eight elements arranged thus /n
--/li      Year
--/li      Month
--/li      DayOfWeek
--/li      Day
--/li      Hour
--/li      Minute
--/li      Second
--/li      Milliseconds
--
--Example:
--/code
--      sequence tm
--      tm = getSystemTime()
--/endcode

global function getSystemTime()
     atom lST
     sequence lResult

     lST = acquire_mem(0, SIZEOF_SYSTEMTIME)
     w32Proc(xGetSystemTime,{lST})

     lResult = fetch_SYSTEMTIME(lST)
     release_mem(lST)
     return lResult

end function

--/topic Utilities
--/func getLocalTime()
--/desc Gets the date and time according to your timezone settings.
--/ret SEQUENCE: The date and time (See below for details)
-- This does not need any parameters. The date and time are returned
-- based on your system's current timezone settings.
--
--The return sequence has eight elements arranged thus /n
--/li      Year
--/li      Month
--/li      DayOfWeek
--/li      Day
--/li      Hour
--/li      Minute
--/li      Second
--/li      Milliseconds
--
--Example:
--/code
--      sequence tm
--      tm = getLocalTime()
--/endcode

global function getLocalTime()
     atom lST
     sequence lResult

     lST = acquire_mem(0, SIZEOF_SYSTEMTIME)
     w32Proc(xGetLocalTime,{lST})

     lResult = fetch_SYSTEMTIME(lST)
     release_mem(lST)
     return lResult

end function

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu