@暗夜魔尊
{ Unix date conversion support with time-zone detect }

function DateTimeToGreenUnix(const AValue: TDateTime; MilliSeconds: Boolean = False): Int64;
var
tzi : TTimeZoneInformation;
GrDt: TDateTime;
begin
GetTimeZoneInformation(tzi);
GrDt := IncHour(AValue, tzi.Bias div 60);
if MilliSeconds then
Result := MilliSecondsBetween(UnixDateDelta, GrDt)
else
Result := SecondsBetween(UnixDateDelta, GrDt);
if GrDt < UnixDateDelta then
Result := -Result;
end;

function GreenUnixToDateTime(const AValue: Int64; MilliSeconds: Boolean = False): TDateTime;
var

tzi : TTimeZoneInformation;
begin
GetTimeZoneInformation(tzi);
if MilliSeconds then
Result := IncMilliSecond(UnixDateDelta, AValue - tzi.Bias * 60 * 1000)
else
Result := IncSecond(UnixDateDelta, AValue - tzi.Bias * 60);
end;

DateTimeToGreenUnix的更多相关文章

随机推荐

  1. tomcat 去除端口和项目名/使用域名访问/修改超链接为IP地址

    1.打开tomcat/conf/server.xml 在host标签中加入 <Context  docBase="项目名" path="" reloada ...

  2. iOS 下载功能:断点下载(暂停和开始)(NSURLConnectionDataDelegate方法)

    1,model文件代码 文件名称:HMFileDownloader.h #import <Foundation/Foundation.h> @interface HMFileDownloa ...

  3. iOS QLPreviewController(Quick Look)快速浏览jpg,PDF,world等

    #import <QuickLook/QuickLook.h> @interface ViewController ()<QLPreviewControllerDataSource, ...

  4. tomcat添加跨域访问功能-Access-Control-Allow-Origin:*

    目标:tomcat服务器提供的接口,不能在其他域中访问的时候,需要增 Access-Control-Allow-Origin:* 直接配置的方法很多,但是我一个没有成功过,所以只能自己写拦截器了. 1 ...

  5. Jsp bug_001

    报错: The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解 ...

  6. On-demand diverse path computation for limited visibility computer networks

    In one embodiment, a source device detects a packet flow that meets criteria for multi-path forwardi ...

  7. jxl导出Excel

    首先先在自己工程中导入jxl的jar包: 疯狂google后找到一段别人的导出excel方法,先备份于下面: import java.io.File; import java.io.FileOutpu ...

  8. Windows Presentation Foundation(WPF)中的数据绑定(使用XmlDataProvider作控件绑定)

    原文:Windows Presentation Foundation(WPF)中的数据绑定(使用XmlDataProvider作控件绑定) ------------------------------ ...

  9. UML该元素的行为为基础的元素

     Behavioral thingsare the dynamic parts of UML models. These are the verbs of a model, representin ...

  10. ASP.NET Core 动作结果 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core 动作结果 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 动作结果 前面的章节中,我们一直使用简单的 C# 类作为控制器. 虽 ...