Differenze tra le versioni di "Ottenere con le risorse della libreria standard C "time.h" la data nella forma "giorno-della-settimana mese giorno ora:min:sec anno""

Da Gambas-it.org - Wikipedia.
(Creata pagina con "Con le funzioni esterne ''time( )'' e ''ctime( )'', contenute nella libreria standard C "/usr/include/time.h", è possibile ottenere la data corrente nella forma stringa "''gi...")
 
Riga 19: Riga 19:
 
   Dim s As String
 
   Dim s As String
 
    
 
    
   time_C(VarPtr(l))
+
   l = time_C(0)
 
      
 
      
 
   s = ctime(VarPtr(l))
 
   s = ctime(VarPtr(l))

Versione delle 21:30, 12 nov 2016

Con le funzioni esterne time( ) e ctime( ), contenute nella libreria standard C "/usr/include/time.h", è possibile ottenere la data corrente nella forma stringa "giorno-della-settimana mese giorno ora:minuti:secondi anno".


Mostriamo un semplice esempio pratico:

Library "libc:6"

' time_t time (time_t *__timer)
' Return the current time and put it in *TIMER if TIMER is not NULL.
Private Extern time_C(__timer As Pointer) As Long Exec "time"

' char *ctime (const time_t *__timer)
' Equivalent to `asctime (localtime (timer))'.
Private Extern ctime(__timer As Pointer) As String


Public Sub Main()
 
 Dim l As Long
 Dim s As String
 
  l = time_C(0)
   
  s = ctime(VarPtr(l))
  Print s
  
End