Bonjour,

J'arrive a convertir la date courante en utc via
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var
  TZI: TTimeZoneInformation;
  b : tdatetime;
begin
  case GetTimeZoneInformation(TZI) of
    TIME_ZONE_ID_STANDARD:
      begin
        b := date_ + (TZI.Bias / 60 / 24);
      end;
    TIME_ZONE_ID_DAYLIGHT:
      begin
        //Result := DateTime + (TZI.Bias / 60 / 24) + TZI.DaylightBias;
        b := date_ + ((TZI.Bias+TZI.DaylightBias) / 60 / 24);
      end
  else
    raise
      Exception.Create('Error converting to UTC Time. Time zone could not be determined.');
  end;
 
  result := formatdatetime('YYYY-MM-DD HH:nn:ss',b);
 
 
end;
J'arrive a connaitre le fuseau horaire courant via
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
var
  TZI: TTimeZoneInformation;
Begin
  GetTimeZoneInformation(TZI);
  memo1.Lines.Add('StandardName:'+TZI.StandardName);
end;
J'arrive a convertir une date locale future en UTC via la classe TZDB:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
var
  LSydneyTZ: TBundledTimeZone;
  LLocal : TDateTime;
begin
  LSydneyTZ := TBundledTimeZone.Create('Europe/Paris');
  LLocal := DateTimePicker_param_mail_date.Date;
  ReplaceTime(LLocal, DateTimePicker_param_mail_heure.Time);
  memo1.Lines.Add(datetimetostr(LSydneyTZ.ToUniversalTime( LLocal)));
end;
Mais je n'arrive pas a "transtyper" la timezone fourni par GetTimeZoneInformation en une timezone utilisable par TBundledTimeZone.

Avez-vous deja eu a convertir une date locale (autre que la date courante) vers l'UTC et si oui comment faites-vous?

Merci,