鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > delphi > >

GMT 时间格式转换到 TDateTime (Delphi)

来源:互联网 作者:佚名 时间:2013-09-05 09:46
GMT 时间格式转换到 TDateTime (Delphi) 1 // GMT 时间格式转换到 TDateTime 2 // 忽略时区 3 function GMT2DateTime( const pSour:PAnsiChar):TDateTime; GetMonthDig( const Value:PAnsiChar):Integer; MonthDig: array [ 1 .. 12 ] of PAnsiChar = 8 ( ,,

GMT 时间格式转换到 TDateTime (Delphi)

1 //GMT 时间格式转换到 TDateTime 2 //忽略时区 3 function GMT2DateTime(const pSour:PAnsiChar):TDateTime; GetMonthDig(const Value:PAnsiChar):Integer; MonthDig:array[1..12] of PAnsiChar = 8 ( ,,,,,,,,,,, ); Index:Integer; Result := 0; AnsiStrIComp(Value,MonthDig[Index]) = Result := Index; 20 Break; 21 end; 22 end; 23 end; A:array[1..32] of Ansichar; 27 P1,P2:PAnsiChar; 28 Len:Integer; 29 wDay,wMonth,wYear,wHour,wMinute,wSec:Word; 30 D:TDateTime; //P1 := ; 33 Result := 0; 34 P1 := pSour; 35 P2 := @A[1]; 36 Len := 31; P2^ := P1^; 40 Inc(P1); 41 Inc(p2); 42 Dec(Len); 43 end; 44 P2^ := #0; 45 46 P1 := @A[1]; ) and (P1^ <>#0)) do Inc(P1);Inc(p1); ((P1^ <> #32) and (P1^ <>#0)) do Inc(P1);Inc(p1);P2 := P1; 51 while((P2^ <> #32) and (P2^ <>#0)) do Inc(P2); P2^ := #0; 52 wDay := StrToIntDef(P1,-1); 53 54 //Aug 55 P1 := P2; Inc(P1);P2 := P1; 56 while( (P2^<>#32) and (P2^ <>#0)) do Inc(P2);P2^ := #0; 57 wMonth := GetMonthDig(P1); Exit; P1 := P2; Inc(P1);P2 := P1; 63 while( (P2^<>#32) and (P2^ <>#0) ) do Inc(P2);P2^ := #0; 64 wYear := StrToIntDef(P1,-1); Exit; 67 68 //Hour 69 P1 := P2; Inc(P1);P2 := P1; ) and (P2^ <>#0)) do Inc(P2);P2^ := #0; 71 wHour := StrToIntDef(P1,-1); Exit; 74 75 //Min 76 P1 := P2; Inc(P1);P2 := P1; ) and (P2^ <>#0)) do Inc(P2);P2^ := #0; 78 wMinute := StrToIntDef(P1,-1); Exit; 81 82 //Sec 83 P1 := P2; Inc(P1);P2 := P1; 84 while((P2^<>#32) and (P2^ <>#0)) do Inc(P2);P2^ := #0; 85 wSec := StrToIntDef(P1,-1); Exit; 88 89 Result := EnCodeDateTime(wYear,wMonth,wDay,wHour,wMinute,wSec,0); ;

 

TDateTime 转换成 GMT 时间格式

1 function DateTimeToGMT(const ADate:TDateTime):string; WEEK:,,,,,,); 4 MonthDig:array[1..12] of PChar = ,,,,,,,,,,,); wWeek,wYear,wMonth,wDay,wHour,wMin,wSec,wMilliSec:Word; 9 A:array[1..32] of AnsiChar; 10 P1,P2:PAnsiChar; 11 sWeek,sMonth:string; DecodeDateTime(ADate,wYear,wMonth,wDay,wHour,wMin,wSec,wMilliSec); 14 wWeek := DayOfWeek(ADate); 15 sWeek := WEEK[wWeek]; 16 sMonth := MonthDig[wMonth]; ,[sWeek,wDay,sMonth,wYear,wHour,wMin,wSec]); 18 end;

 

 

 

posted on

网友评论
<