File tree 3 files changed +16
-4
lines changed
test/functional/android/android
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
3
3
4
4
## [ Unreleased]
5
5
### Enhancements
6
+ - Add a ` format ` argument for ` device_time ` [ #94 ] ( https://github.com/appium/ruby_lib_core/pull/94 )
6
7
7
8
### Bug fixes
8
9
Original file line number Diff line number Diff line change @@ -80,11 +80,15 @@ module Device
80
80
# @!method device_time
81
81
# Get the time on the device
82
82
#
83
- # @return [String]
83
+ # @param [String] format The set of format specifiers. Read https://momentjs.com/docs/ to get the full list of supported
84
+ # datetime format specifiers. The default format is `YYYY-MM-DDTHH:mm:ssZ`,
85
+ # which complies to ISO-8601
86
+ # @return [String] Formatted datetime string or the raw command output if formatting fails
84
87
#
85
88
# @example
86
89
#
87
- # @driver.device_time
90
+ # @driver.device_time #=> "2018-06-12T11:13:31+02:00"
91
+ # @driver.device_time "YYYY-MM-DD" #=> "2018-06-12"
88
92
#
89
93
90
94
####
@@ -523,8 +527,10 @@ def shake
523
527
end
524
528
525
529
add_endpoint_method ( :device_time ) do
526
- def device_time
527
- execute :device_time
530
+ def device_time ( format = nil )
531
+ arg = { }
532
+ arg [ :format ] = format unless format . nil?
533
+ execute :device_time , { } , arg
528
534
end
529
535
end
530
536
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ def test_device_time
76
76
assert Date . parse ( @@driver . device_time ) . is_a? ( Date )
77
77
end
78
78
79
+ def test_device_time_format
80
+ require 'date'
81
+ assert Date . parse ( @@driver . device_time ( 'YYYY-MM-DD' ) ) . is_a? ( Date )
82
+ end
83
+
79
84
def test_context_related
80
85
@@core . wait { scroll_to ( 'Views' ) } . click
81
86
@@core . wait { scroll_to ( 'WebView' ) } . click
You can’t perform that action at this time.
0 commit comments