Skip to content

Commit

Permalink
feat: remove idevicedate (appium#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
umutuzgur authored Aug 19, 2019
1 parent 6cb3945 commit 5ef1cb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
25 changes: 23 additions & 2 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import { errors } from 'appium-base-driver';
import { iosCommands } from 'appium-ios-driver';
import log from '../logger';
import { util } from 'appium-support';
import moment from 'moment';
import { utilities } from 'appium-ios-device';

let commands = {}, helpers = {}, extensions = {};

const MOMENT_FORMAT_ISO8601 = 'YYYY-MM-DDTHH:mm:ssZ';

commands.active = async function active () {
if (this.isWebContext()) {
return await this.executeAtom('active_element', []);
Expand Down Expand Up @@ -97,6 +101,25 @@ commands.getWindowSize = async function getWindowSize (windowHandle = 'current')
}
};

/**
* Retrieves the current device's timestamp.
*
* @param {string} format - The set of format specifiers. Read
* https://momentjs.com/docs/ to get the full list of supported
* datetime format specifiers. The default format is
* `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601
* @returns Formatted datetime string or the raw command output if formatting fails
*/
commands.getDeviceTime = async function getDeviceTime (format = MOMENT_FORMAT_ISO8601) {
log.info('Attempting to capture iOS device date and time');
if (this.isRealDevice()) {
const { timestamp, utcOffset } = await utilities.getDeviceTime(this.opts.udid);
return moment.unix(timestamp).utcOffset(utcOffset).format(format);
} else {
return await iosCommands.general.getDeviceTime.call(this, format);
}
};

// For W3C
commands.getWindowRect = async function getWindowRect () {
const {width, height} = await this.getWindowSize();
Expand Down Expand Up @@ -154,8 +177,6 @@ commands.hideKeyboard = async function hideKeyboard (strategy, ...possibleKeys)
}
};

commands.getDeviceTime = iosCommands.general.getDeviceTime;

commands.getStrings = iosCommands.general.getStrings;

commands.removeApp = async function removeApp (bundleId) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@babel/runtime": "^7.0.0",
"appium-base-driver": "^3.20.0",
"appium-idb": "^0",
"appium-ios-device": "^0.10.1",
"appium-ios-device": "^0.10.2",
"appium-ios-driver": "^4.0.0",
"appium-ios-simulator": "^3.11.0",
"appium-remote-debugger": "^5.1.0",
Expand All @@ -59,7 +59,8 @@
"uuid-js": "^0.7.5",
"ws": "^7.0.0",
"xmldom": "^0.1.27",
"yargs": "^13.1.0"
"yargs": "^13.1.0",
"moment": "^2.24.0"
},
"scripts": {
"clean": "rm -rf node_modules && rm -f package-lock.json && npm install",
Expand Down Expand Up @@ -101,7 +102,6 @@
"mocha": "^6.0.0",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi-reporters": "^1.1.7",
"moment": "^2.22.2",
"pem": "^1.8.3",
"pngjs": "^3.3.1",
"pre-commit": "^1.1.3",
Expand Down

0 comments on commit 5ef1cb2

Please sign in to comment.