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), 时间一, ...
随机推荐
- java调用7zip解压压缩包
前言 最近的项目中需要用到解压缩包的功能,客户给出的压缩包的格式主要是rar和zip,因此就打算使用java调用7zip的命令行进行解压文件,本文主要记录一下实现的过程以及其中遇到的问题. 7zip命 ...
- One special dictionary
由于项目一个功能需要,可以将关键字的值叠加加来,最终可以获取对这些关键字都做了些什么操作. Generic Programming is very powerful. /// <summary& ...
- check_mk检测插件 - raid监控
mk_raidstatus python版本 #!/usr/bin/env python # -*- encoding: utf-8; py-indent-offset: 4 -*- import s ...
- matplotlib安装指南
matplotlib安装指南1.介绍NumPy地址 http://www.numpy.org/NumPy:一个Python一个扩展库,支持大量的维度数组和举证运算,对数组提供大量的函数库 SciPy地 ...
- shell脚本学习(2)比较两个数字大小
注意:shell中对比字符串只能使用==.<.>.!=.-z.-n.对比字符串时,末尾一定要加上x(或者a.b等)一个字符,因为if [ $1x == "ab"x ]时 ...
- Codeforces 758B Blown Garland
题目链接:http://codeforces.com/contest/758/problem/B 题意:一个原先为4色环的链子少了部分,要你找出死的最少的一种可能,各输出四种颜色的死了多少. 分析:就 ...
- 网格中的BFS,逆向(POJ2049)
题目链接:http://poj.org/problem?id=2049 解题报告: 网格中的BFS,最主要的是边界问题. 1.这里在左右,上下两个方向上,分别判断墙,和门,细节是,向上有t个墙,for ...
- Miller rabin
蛤蛤,终于基本上搞懂了 #include<iostream> #include<cstdio> using namespace std; long long num[10]={ ...
- HTTP head meta
HTTP(HyperTextTransferProtocol)即超文本传输协议,目前网页传输的的通用协议.HTTP协议采用了请求/响应模型,浏览器或其他客户端发出请求,服务器给与响应.就整个网络资源传 ...
- 第50章 读写内部FLASH—零死角玩转STM32-F429系列
第50章 读写内部FLASH 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/fire ...