Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time zone formatting for device time getter #557

Merged
merged 3 commits into from
Aug 6, 2019

Conversation

mykola-mokhnach
Copy link
Contributor

By default moment.js uses the local time zone. And we need to enforce the device time zone to be used while formatting the resulting stamp.

Addresses https://discuss.appium.io/t/driver-getdevicetime-works-incorrectly-for-appium-1-7-2/27369/3

Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks 🎉

const deviceTimestamp = (await this.adb.shell(['date', '+%Y-%m-%dT%T%z'])).trim();
const parsedTimestamp = moment(deviceTimestamp, 'YYYY-MM-DDTHH:mm:ssZ');
log.debug(`Got device timestamp: ${deviceTimestamp}`);
const parsedTimestamp = moment.utc(deviceTimestamp, 'YYYY-MM-DDTHH:mm:ssZZ');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(kind of question)
Can we apply only one Z insteaf of ZZ in JS?

> m.utc(a, 'YYYY-MM-DDTHH:mm:ssZ').toString()
'Sat Jun 09 2018 07:21:54 GMT+0000'
> m.utc(a, 'YYYY-MM-DDTHH:mm:ssZZ').toString()
'Sat Jun 09 2018 07:21:54 GMT+0000'

Copy link
Contributor Author

@mykola-mokhnach mykola-mokhnach Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZZ means time zone in format +0000 and Z equals to +00:00. Although, I assume moment parser is smart enough to properly parse the stamp in both cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants