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.

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 condivisa: "libglib-2.0.so.0.7200.4 ".

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

Library "libglib-2.0:0.7200.4"

' 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