//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)的更多相关文章

  1. 问题:Oracle to_date;结果:oracle常用的时间格式转换

    oracle常用的时间格式转换 1:取得当前日期是本月的第几周 SQL> select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from dual; T ...

  2. scala 时间,时间格式转换

    scala 时间,时间格式转换 1.scala 时间格式转换(String.Long.Date) 1.1时间字符类型转Date类型 1.2Long类型转字符类型 1.3时间字符类型转Long类型 2. ...

  3. moment.js 时间格式转换

    moment.js 时间格式转换 moment.js 时间转化 bug 格式错误 bug 02:00 => 14:00 format HH 与 hh HH === 24 小时制 hh === 1 ...

  4. SQL Server日期时间格式转换字符串详解 (详询请加qq:2085920154)

    在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...

  5. SQL Server日期时间格式转换字符串

    在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...

  6. MySQL时间戳和时间格式转换函数

    MySQL时间戳和时间格式转换函数:unix_timestamp and from_unixtime unix_timestamp将时间转化成时间戳格式.from_unixtime将时间戳转化成时间格 ...

  7. Sql日期时间格式转换;取年 月 日,函数:DateName()、DATEPART()

    一.sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, 20) 结果:2007 ...

  8. SQL Server日期时间格式转换字符串详解

    本文我们主要介绍了SQL Server日期时间格式转换字符串的相关知识,并给出了大量实例对其各个参数进行对比说明,希望能够对您有所帮助. 在SQL Server数据库中,SQL Server日期时间格 ...

  9. sql 日期时间格式转换

    Sql日期时间格式转换   sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(16), 时间一, ...

随机推荐

  1. [LeetCode]17. Letter Combinations of a Phone Number电话号码的字母组合

    Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...

  2. Flask文件目录----- auth/blog 文件

    import functools from flask import (Blueprint, flash, g, redirect, render_template, url_for, request ...

  3. css取消a标签在移动端点击时的背景颜色

    一.取消a标签在移动端点击时的蓝色 -webkit-tap-highlight-color: rgba(255, 255, 255, 0);-webkit-user-select: none;-moz ...

  4. 栅格那点儿事(四E)

    栅格金字塔   如果上面的部分都已经看过了,那么如何在ArcMap中更好的渲染一个栅格数据你已经知道了.可仅展示好一个栅格数据是不够的,我们还需要知道如何快速的展示一个栅格数据. 讲金字塔之前,先解释 ...

  5. 【工作中学习】CreateProcessAsUser失败,错误码:1314

    事情起因是这样, 产品的Windows服务(Service)之前一直是用Local System Account在运行的,但这个版本有需求要换成使用普通的Domain User来运行,如下图: 但却出 ...

  6. Apache common-io AutoCloseInputStream 分析

    Apache common-io 包是常用的工具包,他提供了对IO操作的一些封装.首先看一下input包下的 AutoCloseInputStream 类 1: * This class is typ ...

  7. Office加载项对Excel进行读写操作

    转载自我的个人主页 前言 在开发ExcelWeb插件的时候,一大亮点就是可以在web项目中操作Excel,读取Excel的内容,也可以将服务端的数据写入的 Excel中,大大方便的用户使用Excel, ...

  8. 2.eclipse安装

    1.进入官网https://www.eclipse.org/ 2.配置工作目录:存放 1.项目代码    2.IDE相关配置信息 3.没有配置tomcat,所以为空.

  9. Vue.js-创建Vue项目(Vue项目初始化)并不是用Webstrom创建,只是用Webstrom打开

    我犯的错误:作为vue小白,并不知道还要单独去创建初始的vue项目,于是自己在webstrom中建了一个Empty Project, 在其中新增了一个js文件,就开始import Vue from “ ...

  10. ASP.NET Core - VSCode安装和配置

    在深入了解ASP.NET Core之前先研究了下主要的两个开发工具(VS 2015和VS Code), VS 2015对Core的支持已经相当的完备,很多操作得到简化用起来很是方便.VS Code是微 ...