Differenze tra le versioni di "Ottenere l'orario locale comprensivo dei microsecondi con la funzione esterna g date time get microsecond() del API di GLIB"

Da Gambas-it.org - Wikipedia.
Riga 14: Riga 14:
 
  ' ''Retrieves the microsecond of the date represented by datetime.''</font>
 
  ' ''Retrieves the microsecond of the date represented by datetime.''</font>
 
  Private Extern g_date_time_get_microsecond(datetime As Pointer) As Integer
 
  Private Extern g_date_time_get_microsecond(datetime As Pointer) As Integer
 +
 +
<FONT Color=gray>' ''void g_date_time_unref (GDateTime *datetime)''
 +
' ''Atomically decrements the reference count of datetime by one.''</font>
 +
Private Extern g_date_time_unref(datetime As Pointer)
 
   
 
   
 
   
 
   
Riga 23: Riga 27:
 
    
 
    
 
   Print CDate(Time(Now)); ".\e[31m"; g_date_time_get_microsecond(dt); "\e[0m"
 
   Print CDate(Time(Now)); ".\e[31m"; g_date_time_get_microsecond(dt); "\e[0m"
 +
 
 +
  g_date_time_unref(dt)
 
    
 
    
 
  '''End'''
 
  '''End'''
 +
  
  

Versione delle 04:28, 2 feb 2018

Per ottenere l'orario locale comprensivo dei microsecondi, si potrà utilizzare la funzione esterna "g_date_time_get_microsecond( )" del API di GLIB-2.0 .

E' necessario avere installata nel sistema e richiamare in Gambas la libreria dinamica condivisa: "libglib-2.0.so"


Mostriamo un semplice esempio pratico (la parte dei microsecondi apparirà in console colorata di rosso):

Library "libglib-2.0"

' GDateTime * g_date_time_new_now_local (void)
' Creates a GDateTime corresponding to this exact instant in the local time zone.
Private Extern g_date_time_new_now_local() As Pointer

' gint g_date_time_get_microsecond (GDateTime *datetime)
' Retrieves the microsecond of the date represented by datetime.
Private Extern g_date_time_get_microsecond(datetime As Pointer) As Integer

' void g_date_time_unref (GDateTime *datetime)
' Atomically decrements the reference count of datetime by one.
Private Extern g_date_time_unref(datetime As Pointer)


Public Sub Main()
 
 Dim dt As Pointer
  
  dt = g_date_time_new_now_local()
  
  Print CDate(Time(Now)); ".\e[31m"; g_date_time_get_microsecond(dt); "\e[0m"
  
  g_date_time_unref(dt)
  
End



Riferimenti