@@ -523,9 +523,26 @@ def update_settings(self, settings):
523523
524524 @property
525525 def device_time (self ):
526- """Returns the date and time from the device
526+ """Returns the date and time from the device.
527527 """
528- return self .execute (Command .GET_DEVICE_TIME , {})['value' ]
528+ return self .execute (Command .GET_DEVICE_TIME_GET , {})['value' ]
529+
530+ def get_device_time (self , format = None ):
531+ """Returns the date and time from the device. (Only available since Appium 1.11.0)
532+
533+ :Args:
534+ - format - (optional) The set of format specifiers. Read https://momentjs.com/docs/
535+ to get the full list of supported datetime format specifiers.
536+ If unset, return :func:`.device_time` as default format is `YYYY-MM-DDTHH:mm:ssZ`,
537+ which complies to ISO-8601
538+
539+ :Usage:
540+ self.driver.get_device_time()
541+ self.driver.get_device_time("YYYY-MM-DD")
542+ """
543+ if format is None :
544+ return self .device_time
545+ return self .execute (Command .GET_DEVICE_TIME_POST , {'format' : format })['value' ]
529546
530547 @property
531548 def battery_info (self ):
@@ -584,7 +601,9 @@ def _addCommands(self):
584601 ('POST' , '/session/$sessionId/appium/settings' )
585602 self .command_executor ._commands [Command .LOCATION_IN_VIEW ] = \
586603 ('GET' , '/session/$sessionId/element/$id/location_in_view' )
587- self .command_executor ._commands [Command .GET_DEVICE_TIME ] = \
604+ self .command_executor ._commands [Command .GET_DEVICE_TIME_GET ] = \
588605 ('GET' , '/session/$sessionId/appium/device/system_time' )
606+ self .command_executor ._commands [Command .GET_DEVICE_TIME_POST ] = \
607+ ('POST' , '/session/$sessionId/appium/device/system_time' )
589608 self .command_executor ._commands [Command .CLEAR ] = \
590609 ('POST' , '/session/$sessionId/element/$id/clear' )
0 commit comments