convertTimeByTimeZone

convertTimeByTimeZone(localTimestamp: TimeStamp
                      foreignTimeZone: JadeTimeZone): TimeStamp;

The convertTimeByTimeZone method of the JadeTimeZone class converts the timestamp of the local time zone specified in the localTimestamp parameter to the timestamp of the foreign time zone specified in the foreignTimeZone parameter, accounting for daylight saving and any historical time zone information available in both time zones.

The following example shows the use of the convertTimeByTimeZone method that converts time between Rome and New York when the clock strikes 12.

example_convertTimeByTimeZone();
vars
    romeDate: Date;
    romeTime: Time;
    romeTimeStamp: TimeStamp;
    romeTimeZone: JadeTimeZone;
    newYorkTimeStamp: TimeStamp;
    newYorkTimeZone: JadeTimeZone;
begin
    romeTime.setTime(0,0,0,0); // Set the time in Rome to midnight
    romeDate.setDate(1,1,2020); // Set the day in Rome to the 1st of January 2020
    romeTimeStamp.setTime(romeTime);
    romeTimeStamp.setDate(romeDate);
    romeTimeZone := JadeTimeZone@createTimeZoneByName("Europe/Rome"); 
               // Create a JadeTimeZone for Rome
    newYorkTimeZone := JadeTimeZone@createTimeZoneByName("America/New_York");
               // Create a JadeTimeZone for New York
    newYorkTimeStamp := romeTimeZone.convertTimeByTimeZone(romeTimeStamp, 
               newYorkTimeZone); // Convert the time for Rome zone to New York time
    write "The time in New York when the clock strikes twelve in Rome is 
             " & newYorkTimeStamp.String;
epilog
    delete romeTimeZone;
    delete newYorkTimeZone;
end;

2020.0.01 and higher