将TDateTime转换到另一个时区,无论本地时区如何 [英] Convert TDateTime to Another Time Zone Regardless of Local Time Zone

查看:382
本文介绍了将TDateTime转换到另一个时区,无论本地时区如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论用户的本地时区设置为什么,使用Delphi 2007,我需要确定东部时区的时间(TDateTime)。

Regardless of what the user's local time zone is set to, using Delphi 2007, I need to determine the time (TDateTime) in the Eastern time zone.

我能做到吗当然,需要了解夏令时间。

How can I do that? Of course, needs to be daylight savings time aware.

推荐答案

TDateTime没有任何时区信息(它只是一个双重的 - 作为整数的日期,小时的时间),所以你需要分开。您也需要自己的DST逻辑,我不相信Delphi中有任何内容。然后使用DateUtils.pas中的IncHour函数将TDateTime更改为东部时区。

TDateTime does not have any time zone information (it is just a double - date as whole number, time as decimal), so you would need that separately. You would need your own logic for DST as well, I don't believe there is any in Delphi. Then use the IncHour function in DateUtils.pas to alter the TDateTime to the Eastern Timezone.

可能会为您提供Web服务。您的应用程序是否需要自包含,或者可以连接到网络来执行?

There are probably web services that will do this for you. Does your application need to be self contained, or can it connect to the web to do it?

这篇关于将TDateTime转换到另一个时区,无论本地时区如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆