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), 时间一, ...
随机推荐
- js弹出页面
建立一个HTML文件,输入以下代码就能弹出页面 <!DOCTYPE html> <html lang="en"> <head> <meta ...
- SpringBoot系列之——整合JPA、mysql
一.JPA 1. 概念:JPA顾名思义就是Java Persistence API的意思,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中. 2. ...
- iOS 上滑隐藏导航,下滑显示导航,仿斗鱼导航效果
UItableView或 UIcollectionView 都是继承UIScrollView 滑动的时候,判断是上滑还是下滑 使用 UIScrollView 的代理方法 func scrollView ...
- [LeetCode]11. Container With Most Water 盛最多水的容器
Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). ...
- ping过程详解
原出处:http://wanicy.blog.51cto.com/509018/335207/ PS:这里只是给出了ping ip地址的例子,没有给出ping域名的例子. ping 域名还有域名转换成 ...
- Controller的使用
- android selector中使用shape
<shape> <!-- 实心 --> <solid android:color="#ff9d77"/> <!-- 渐变 --&g ...
- 笨办法学Python(十七)
习题 17: 更多文件操作 现在让我们再学习几种文件操作.我们将编写一个 Python 脚本,将一个文件中的内容拷贝到另外一个文件中.这个脚本很短,不过它会让你对于文件操作有更多的了解. from s ...
- winform datagridview 如何设置datagridview隔行变色
如何设置隔行变色. 如图:
- Educational Codeforces Round 14 - F (codeforces 691F)
题目链接:http://codeforces.com/problemset/problem/691/F 题目大意:给定n个数,再给m个询问,每个询问给一个p,求n个数中有多少对数的乘积≥p 数据范围: ...