1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| // definir un objet ayant une propriete "caption" où est
// ecrit les 2 heures loc et gmt
time_t t = time(NULL); // initialisation a NULL necessaire
struct tm *TM;
unsigned short h,m,s;
TM = localtime(&t); // pointeur sur structure tm donc adresse et pas heure directement. acceder a l'heure comme suit!
h = ((tm)(*TM)).tm_hour;
m = ((tm)(*TM)).tm_min;
s = ((tm)(*TM)).tm_sec;
Caption = "Heure Locale : " + IntToStr(h) + ":" + IntToStr(m) + ":" + IntToStr(s);
TM = gmtime(&t); // pointeur sur structure tm cette adresse peut etre la meme que precedement!!! mais la valeur pointée a changé
h = ((tm)(*TM)).tm_hour;
m = ((tm)(*TM)).tm_min;
s = ((tm)(*TM)).tm_sec;
Caption = Caption + " Heure GMT : " + IntToStr(h) + ":" + IntToStr(m) + ":" + IntToStr(s); |
Partager