828
社区成员
发帖
与我相关
我的任务
分享
uses DateUtils;
function ConvertPDTDateTime(Str: string): TDateTime;
const
EngMonthName: array[1..12] of string = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var
I: Integer;
fs: TFormatSettings;
begin
fs.ShortDateFormat := 'mm-dd-yy';
fs.LongDateFormat := 'mm-dd-yyyyy';
fs.DateSeparator := '-';
fs.TimeSeparator := ':';
fs.LongTimeFormat := 'hh:nn:ss';
fs.ShortTimeFormat := 'hh:nn:ss';
fs.TwoDigitYearCenturyWindow := 50;
for I := 1 to 12 do
begin
Str := StringReplace(Str, EngMonthName[I], IntToStr(I), [rfIgnoreCase]);
end;
Result := StrToDateTime(Str, fs);
//PDT是Pacific Daylight Time的简称,意思是太平洋夏令时
//指的是美国西部时间
//-8区 和北京平时差16小时 4-10月夏令时差15小时
if Pos('PDT', Str) > 0 then
begin
if MonthOf(Result) in [4..10] then
Result := IncHour(Result, 15)
else
Result := IncHour(Result, 16);
end;
end;