0

我们已经尝试使用 IST 减去 IST 和 CST 之间的差异,以便我们可以获得 CST 时间(SUT 的时间),但是当夏令时到来时它就不起作用了。请有人帮助获得 SUT 时间。

4

1 回答 1

0

您不能直接从 SUT 获取时区。有几种方法可以完成您要完成的工作:

1. 截屏 SUT 上的时间。

使用 OCR,隔离the searchRectangle到系统的时钟。然后readtext()将读取的文本保存到变量myTime中。


2. 远程命令(仅限移动 SUT)。

您可以使用 Eggplant 函数向 SUT 发送远程命令ExecuteRemoteCommand()来自茄子的文档

  • “在 Android 上,ExecuteRemoteCommand 在实际手机上作为 shell 命令运行。

  • 在 iOS 上,ExecuteRemoteCommand 作为 JavaScript 运行命令,调用 Apple UIAutomation API。”

您可以将这些命令的输出保存到一个变量中,因此在 Android SUT 上它将是:

set SUT_time to ExecuteRemoteCommand(date)

SUT_time现在将表示格式中的时间Mon Jul 31 21:09:28 CDT 2017


3. 数学!

鉴于您当前系统的日期和时间,您应该始终能够计算任何给定时区的时间。目前,这将作为:

set SUT_time to the date minus 10 hours 30 minutes

为了使其与夏令时兼容,您必须使用if语句。这可能看起来像这样:

set CST to the date minus 10 hours 30 minutes
if CST is between "Mar 11" and "Nov 4" then
    add 1 hour to CST
end if
于 2018-07-27T14:10:20.143 回答