@greatdayhr/capacitor-datetime-setting 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = '
|
|
6
|
+
s.name = 'GreatdayhrCapacitorDatetimeSetting'
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.license = package['license']
|
|
@@ -6,8 +6,8 @@ import Capacitor
|
|
|
6
6
|
*
|
|
7
7
|
* Capacitor plugin to check auto time/timezone settings and open device settings.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* iOS implementation uses TimeZone.autoupdatingCurrent to determine
|
|
10
|
+
* if the device is set to automatically update its time zone and date/time settings.
|
|
11
11
|
*/
|
|
12
12
|
@objc(DateTimeSettingPlugin)
|
|
13
13
|
public class DateTimeSettingPlugin: CAPPlugin {
|
|
@@ -15,44 +15,41 @@ public class DateTimeSettingPlugin: CAPPlugin {
|
|
|
15
15
|
/**
|
|
16
16
|
* Check if automatic time is enabled on the device.
|
|
17
17
|
*
|
|
18
|
-
* iOS
|
|
19
|
-
*
|
|
20
|
-
* to determine if automatic date/time is enabled.
|
|
21
|
-
*
|
|
22
|
-
* When auto date/time is ON: autoupdatingCurrent equals system timezone
|
|
23
|
-
* When auto date/time is OFF: they may differ
|
|
18
|
+
* iOS implementation uses TimeZone.autoupdatingCurrent to determine
|
|
19
|
+
* if the device is set to automatically update its time zone and date/time settings.
|
|
24
20
|
*/
|
|
25
21
|
@objc func timeIsAuto(_ call: CAPPluginCall) {
|
|
26
|
-
let
|
|
27
|
-
let systemTimeZone = NSTimeZone.system
|
|
28
|
-
|
|
29
|
-
// If they are equal, auto date/time is likely enabled
|
|
30
|
-
let isAutoEnabled = autoUpdatingTimeZone.isEqual(to: systemTimeZone)
|
|
31
|
-
|
|
22
|
+
let isAuto = checkAutoDateTime()
|
|
32
23
|
call.resolve([
|
|
33
|
-
"value":
|
|
24
|
+
"value": isAuto
|
|
34
25
|
])
|
|
35
26
|
}
|
|
36
27
|
|
|
37
28
|
/**
|
|
38
29
|
* Check if automatic timezone is enabled on the device.
|
|
39
30
|
*
|
|
40
|
-
* iOS
|
|
41
|
-
*
|
|
42
|
-
* This is because iOS doesn't separate auto time and auto timezone settings.
|
|
31
|
+
* iOS implementation uses TimeZone.autoupdatingCurrent to determine
|
|
32
|
+
* if the device is set to automatically update its time zone.
|
|
43
33
|
*/
|
|
44
34
|
@objc func timeZoneIsAuto(_ call: CAPPluginCall) {
|
|
45
|
-
let
|
|
46
|
-
let systemTimeZone = NSTimeZone.system
|
|
47
|
-
|
|
48
|
-
// If they are equal, auto timezone is likely enabled
|
|
49
|
-
let isAutoEnabled = autoUpdatingTimeZone.isEqual(to: systemTimeZone)
|
|
50
|
-
|
|
35
|
+
let isAuto = checkAutoDateTime()
|
|
51
36
|
call.resolve([
|
|
52
|
-
"value":
|
|
37
|
+
"value": isAuto
|
|
53
38
|
])
|
|
54
39
|
}
|
|
55
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Helper method to check if auto date/time is enabled.
|
|
43
|
+
*
|
|
44
|
+
* Compares the autoupdating timezone with the system timezone.
|
|
45
|
+
* If they are equal, auto date/time is enabled.
|
|
46
|
+
*/
|
|
47
|
+
private func checkAutoDateTime() -> Bool {
|
|
48
|
+
let autoUpdatingTimeZone = TimeZone.autoupdatingCurrent
|
|
49
|
+
let systemTimeZone = TimeZone.current
|
|
50
|
+
return autoUpdatingTimeZone == systemTimeZone
|
|
51
|
+
}
|
|
52
|
+
|
|
56
53
|
/**
|
|
57
54
|
* Open the device's Settings app.
|
|
58
55
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greatdayhr/capacitor-datetime-setting",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Capacitor plugin to get information about auto time and auto timezone, open setting if not set to auto",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"android/src",
|
|
12
12
|
"dist/",
|
|
13
13
|
"ios/Plugin/",
|
|
14
|
-
"
|
|
14
|
+
"GreatdayhrCapacitorDatetimeSetting.podspec"
|
|
15
15
|
],
|
|
16
16
|
"author": "rakaraka029",
|
|
17
17
|
"license": "MIT",
|