Gambas France BETA


Pas de compte ? Incription

Conversion secondes en heure minute.

1
AuteurMessages
noucom#1 Posté le 24/11/2015 à 16:04:44
Bonsoir,
Existe t il une fonction toute prete pour convertir 3250 seconde en heure minute seconde sous ce format :

xh 2min 5sec
vuott#2 Posté le 24/11/2015 à 18:31:11
Ne cedere ineluctabili possimus....je propose ce code: :|

1
2
3
4
5
6
7
PUBLIC SUB Main()

DIM i AS INTEGER = 3250

PRINT Format$(Date(0, 0, 0, 0, 0, 0, i * 1000), "h\\h n\\mi\\n s\\sec")

END



...si cependant il te plaît te compliquer la vie, tu peux utiliser les fonctions extérieures de la librairie GLIB: :rabbit:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PUBLIC STRUCT GTimeVal
tv_sec AS LONG
tv_usec AS LONG
END STRUCT

LIBRARY "libglib-2.0"

' GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv)
' Creates a GDateTime corresponding to the given GTimeVal tv in UTC.
PRIVATE EXTERN g_date_time_new_from_timeval_utc(tv AS GTimeVal) AS POINTER

' gchar * g_date_time_format (GDateTime *datetime, const gchar *format)
' Creates a newly allocated string representing the requested format.
PRIVATE EXTERN g_date_time_format(datetime AS GTimeVal, gformat AS STRING) AS STRING


PUBLIC SUB Main()

DIM GTv AS NEW GTimeVal
DIM dt AS POINTER

GTv.tv_sec = 3250

dt = g_date_time_new_from_timeval_utc(GTv)

PRINT g_date_time_format(dt, "%kh %Mmin %Ssec")

END




Salut
« Vita non suavis esse potest, nec Mors amara. »
1