GMT 时间格式转换到 TDateTime (Delphi)
//GMT 时间格式转换到 TDateTime
//忽略时区
function GMT2DateTime(const pSour:PAnsiChar):TDateTime; function GetMonthDig(const Value:PAnsiChar):Integer;
const
MonthDig:array[..] of PAnsiChar =
(
'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'
);
var
Index:Integer;
begin
Result := ;
for Index := to do
begin
if AnsiStrIComp(Value,MonthDig[Index]) = then
begin
Result := Index;
Break;
end;
end;
end; var
A:array[..] of Ansichar;
P1,P2:PAnsiChar;
Len:Integer;
wDay,wMonth,wYear,wHour,wMinute,wSec:Word;
D:TDateTime;
begin
//P1 := ' Mon, 12 Aug 2013 16:20:35 GMT';
Result := ;
P1 := pSour;
P2 := @A[];
Len := ;
while((Len > ) and (P1^ <>#)) do
begin
P2^ := P1^;
Inc(P1);
Inc(p2);
Dec(Len);
end;
P2^ := #; P1 := @A[];
while((P1^<>',') and (P1^ <>#)) do Inc(P1);Inc(p1); //
while((P1^ <> #) and (P1^ <>#)) do Inc(P1);Inc(p1);P2 := P1;
while((P2^ <> #) and (P2^ <>#)) do Inc(P2); P2^ := #;
wDay := StrToIntDef(P1,-); //Aug
P1 := P2; Inc(P1);P2 := P1;
while( (P2^<>#) and (P2^ <>#)) do Inc(P2);P2^ := #;
wMonth := GetMonthDig(P1);
if wMonth = then
Exit; //
P1 := P2; Inc(P1);P2 := P1;
while( (P2^<>#) and (P2^ <>#) ) do Inc(P2);P2^ := #;
wYear := StrToIntDef(P1,-);
if wYear = then
Exit; //Hour
P1 := P2; Inc(P1);P2 := P1;
while((P2^<>':') and (P2^ <>#)) do Inc(P2);P2^ := #;
wHour := StrToIntDef(P1,-);
if wHour < then
Exit; //Min
P1 := P2; Inc(P1);P2 := P1;
while((P2^<>':') and (P2^ <>#)) do Inc(P2);P2^ := #;
wMinute := StrToIntDef(P1,-);
if wMinute < then
Exit; //Sec
P1 := P2; Inc(P1);P2 := P1;
while((P2^<>#) and (P2^ <>#)) do Inc(P2);P2^ := #;
wSec := StrToIntDef(P1,-);
if wSec < then
Exit; Result := EnCodeDateTime(wYear,wMonth,wDay,wHour,wMinute,wSec,); end;
TDateTime 转换成 GMT 时间格式
function DateTimeToGMT(const ADate:TDateTime):string;
const
WEEK:array[..] of PChar = ('Sun','Mon','Tues','Wed','Thur','Fri','Sat');
MonthDig:array[..] of PChar =
('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var
wWeek,wYear,wMonth,wDay,wHour,wMin,wSec,wMilliSec:Word;
A:array[..] of AnsiChar;
P1,P2:PAnsiChar;
sWeek,sMonth:string;
begin
DecodeDateTime(ADate,wYear,wMonth,wDay,wHour,wMin,wSec,wMilliSec);
wWeek := DayOfWeek(ADate);
sWeek := WEEK[wWeek];
sMonth := MonthDig[wMonth];
Result := Format(' %s, %d %s %d %d:%d:%d GMT',[sWeek,wDay,sMonth,wYear,wHour,wMin,wSec]);
end;
GMT 时间格式转换到 TDateTime (Delphi)的更多相关文章
- 问题:Oracle to_date;结果:oracle常用的时间格式转换
oracle常用的时间格式转换 1:取得当前日期是本月的第几周 SQL> select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from dual; T ...
- scala 时间,时间格式转换
scala 时间,时间格式转换 1.scala 时间格式转换(String.Long.Date) 1.1时间字符类型转Date类型 1.2Long类型转字符类型 1.3时间字符类型转Long类型 2. ...
- moment.js 时间格式转换
moment.js 时间格式转换 moment.js 时间转化 bug 格式错误 bug 02:00 => 14:00 format HH 与 hh HH === 24 小时制 hh === 1 ...
- SQL Server日期时间格式转换字符串详解 (详询请加qq:2085920154)
在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...
- SQL Server日期时间格式转换字符串
在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...
- MySQL时间戳和时间格式转换函数
MySQL时间戳和时间格式转换函数:unix_timestamp and from_unixtime unix_timestamp将时间转化成时间戳格式.from_unixtime将时间戳转化成时间格 ...
- Sql日期时间格式转换;取年 月 日,函数:DateName()、DATEPART()
一.sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007 ...
- SQL Server日期时间格式转换字符串详解
本文我们主要介绍了SQL Server日期时间格式转换字符串的相关知识,并给出了大量实例对其各个参数进行对比说明,希望能够对您有所帮助. 在SQL Server数据库中,SQL Server日期时间格 ...
- sql 日期时间格式转换
Sql日期时间格式转换 sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, ...
随机推荐
- FastDFS 基础知识
FastDFS是一个开源的轻量级分布式文件系统,它用纯C语言实现,支持Linux.FreeBSD.AIX等UNIX系统.它只能通过专有API对文件进行存取访问,不支持POSIX接口方式,不能mount ...
- #include stdio.h(3)
#include <stdio.h> int main() { /* * ** *** **** ***** */ ;a<;a++) { printf("\n") ...
- [RabbitMQ]Windows环境下rabbitmqclt(Command Line Tools)出现Erlang distribution failed错误的解决方法
摘要 当使用rabbitmqctl时出现Erlang distribution failed,把%SystemRoot%Windows\System32\config\systemprofile下的. ...
- 移动端absolute元素居中
<div class="db"> <div class="dm"></div> </div> .db{ widt ...
- android api 之Scroller
Scroller是封装了滚动,实现View和ViewGroup的背景画布的滚动. 它有两个构造方法: public Scroller (Context context) 传递一个上下文. public ...
- SpringMVC快速入门
导入开发包 前6个是Spring的核心功能包[IOC],第7个是关于web的包,第8个是SpringMVC包 org.springframework.context-3.0.5.RELEASE.jar ...
- lottie使用
dependencies { implementation 'com.airbnb.android:lottie:2.5.5' } 动画素材地址:https://www.lottiefiles.com ...
- SaberSama【css总结】
为什么要转过来呢? 因为我觉到,同样是一个初学者,应该互相学习,交流. css:Cascading Style Sheets 层叠样式表 CSS引入方式: 1.内嵌: <p style=&quo ...
- Node.js-sublime text3 配置node.js(ERROR: The process "node.exe" not found.)
默认已经安装好sublime.node和npm 1.sublime的node.js插件下载 由于在package control上经常下载失败,所以这里直接从GitHub上进行下载! GitHub下载 ...
- 详解如何利用FarPoint Spread表格控件来构造Winform的Excel表格界面输入
我们先来简单了解一下WinForm和FarPoint,WinForm是·Net开发平台中对Windows Form的一种称谓.而FarPoint是一款模拟EXCEL的控件.它可以根据用户的要求实现很大 ...