お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"国際標準時とローカル時間の相互変換"






TDateTime型のローカル時間を、国際標準時に変換。また、その逆。
タイムゾーンが日本のときは、9時間の差。

function LocalDateTimeToUTC(Value: TDateTime): TDateTime;
var
  s: TSystemTime;
  f1, f2: TFileTime;
begin
  DateTimeToSystemTime(Value, s);
  SystemTimeToFileTime(s, f1);
  LocalFileTimeToFileTime(f1, f2);
  FileTimeToSystemTime(f2, s);
  Result := SystemTimeToDateTime(s);
end;

function UTCToLocalDateTime(Value: TDateTime): TDateTime;
var
  s: TSystemTime;
  f1, f2: TFileTime;
begin
  DateTimeToSystemTime(Value, s);
  SystemTimeToFileTime(s, f1);
  FileTimeToLocalFileTime(f1, f2);
  FileTimeToSystemTime(f2, s);
  Result := SystemTimeToDateTime(s);
end;

                                     00/06/06(火) 00:07 東洞31(CZB13222)

Original document by 東洞31        氏 ID:(CZB13222)


ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum