driver.getDeviceTime() works incorrectly for Appium > 1.7.2

Hi. Method driver.getDeviceTime() returns incorrectly time. It returns PC time, but not device time.

Usually, it not noticeable, because PC and connected device have one timezone. But I use Sause labs for testing and can’t get correctly device time.

This issue valid for Appium version above 1.7.2

For Appium 1.7.2 and below, driver.getDeviceTime() works correctly.

Appium log for getDeviceTime()

[2019-08-02 04:20:40][HTTP] 
[2019-08-02 04:20:40][HTTP] --> GET /wd/hub/session/07c457c8-4292-44e8-93de- 
[2019-08-02 04:20:40][HTTP] {}
[2019-08-02 04:20:40][W3C (07c457c8)] Calling AppiumDriver.getDeviceTime() with args: 
[2019-08-02 04:20:40][AndroidDriver] Attempting to capture android device date and time
[2019-08-02 04:20:40][ADB] Running '/Users/ysmirnova/Library/Android/sdk/platform-tools/adb -P 
5037 -s 52000031f48c8431 shell date +%Y-%m-%dT%T%z'
[2019-08-02 04:20:40][W3C (07c457c8)] Responding to client with driver.getDeviceTime() result: 
[2019-08-02 04:20:40][HTTP] <-- GET /wd/hub/session/07c457c8-4292-44e8-93de- 
f75c91b2d8e3/appium/device/system_time 200 99 ms - 37
[2019-08-02 04:20:40][HTTP] 

Adb shell date console output

$ adb shell date
Fri Aug  2 20:24:08 +07 2019

what is the output of adb shell date +%Y-%m-%dT%T%z ?

Appium log:
[2019-08-05 11:06:22][ADB] Running ‘/Users/ysmirnova/Library/Android/sdk/platform-tools/adb -
P 5037 -s 52000031f48c8431 shell date +%Y-%m-%dT%T%z’
[2019-08-05 11:06:22][W3C (a41c127b)] Responding to client with driver.getDeviceTime() result:

Adb shell date console output - it returns correct device time
$ adb shell date +%Y-%m-%dT%T%z

This was a bug in the time converter implementation. Pushed a PR with a fix for it:

1 Like

The fix has been published to appium@beta

1 Like