Delphi:使用 XSDateTime 而不将时间转换为本地时区

发布于 2024-12-22 04:59:35 字数 427 浏览 3 评论 0原文

我正在 Delphi 中编程并使用一个 API,该 API 返回代表约会时间段的 XSDateTime。当我尝试创建本地数据时间时,时间将转换为我的 EST 时区(Z-05:00 或 Z-04:00,具体取决于 DST)。我需要时间保留在 CST 的原始时区 (Z-06:00)。我目前正在按如下方式格式化时间:

aApptListing := FormatDateTime('yyyy/mm/dd t', aSlots[i].StartDateTime.AsDateTime);

其中 StartDateTime 为 CST 时间 (Z-06:00)。如何保留原来的 CST 时间?例如,如果通过 API 提供的日期/时间为“2011-12-25T08:00:00-06:00”,我想显示 12/25/2011 @ 8:00 AM,而不是 9:00 AM是美国东部时间。

I am programming in Delphi and consuming an API that returns an XSDateTime representing an appointment timeslot. When I try to create a local datatime the time is being converted to my EST timezone (Z-05:00 or Z-04:00 depending on DST). I need the time to remain in the original timezone of CST (Z-06:00). I am currently formatting the time as follows:

aApptListing := FormatDateTime('yyyy/mm/dd t', aSlots[i].StartDateTime.AsDateTime);

where StartDateTime comes in as the time in CST (Z-06:00). How can I keep the original time for CST? For instance, if the date/time comes thru the API as '2011-12-25T08:00:00-06:00' I want to show 12/25/2011 @ 8:00 AM, not 9:00 AM which would be EST.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2024-12-29 04:59:35

看起来以下应该有效:

with aSlots[i].StartDateTime do
  aApptListing := FormatDateTime('yyyy/mm/dd t', EncodeDateTime(Year, Month, Day, Hour, Minute, Second, 0));

It looks like the following should work:

with aSlots[i].StartDateTime do
  aApptListing := FormatDateTime('yyyy/mm/dd t', EncodeDateTime(Year, Month, Day, Hour, Minute, Second, 0));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文