react-native-timezone 3.0.1 → 3.1.0
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.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/android/build.gradle +19 -9
- package/android/generated/java/com/samitha/timezone/NativeTimezoneSpec.java +50 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNTimezoneSpec-generated.cpp +50 -0
- package/android/generated/jni/RNTimezoneSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNTimezoneSpec/RNTimezoneSpecJSI-generated.cpp +48 -0
- package/android/generated/jni/react/renderer/components/RNTimezoneSpec/RNTimezoneSpecJSI.h +94 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/samitha/timezone/TimezoneModule.kt +86 -0
- package/android/src/main/java/com/samitha/timezone/TimezonePackage.kt +34 -0
- package/ios/Timezone.h +1 -7
- package/ios/Timezone.mm +38 -33
- package/ios/generated/RNTimezoneSpec/RNTimezoneSpec-generated.mm +60 -0
- package/ios/generated/RNTimezoneSpec/RNTimezoneSpec.h +62 -0
- package/ios/generated/RNTimezoneSpecJSI-generated.cpp +48 -0
- package/ios/generated/RNTimezoneSpecJSI.h +94 -0
- package/lib/commonjs/NativeTimezone.js.map +1 -1
- package/lib/commonjs/index.js +7 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeTimezone.js +2 -0
- package/lib/module/NativeTimezone.js.map +1 -1
- package/lib/module/index.js +5 -15
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeTimezone.d.ts +10 -0
- package/lib/typescript/commonjs/src/NativeTimezone.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +8 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeTimezone.d.ts +10 -0
- package/lib/typescript/module/src/NativeTimezone.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +8 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +67 -38
- package/react-native-timezone.podspec +19 -21
- package/react-native.config.js +12 -0
- package/src/NativeTimezone.ts +4 -3
- package/src/index.tsx +4 -25
- package/android/src/main/java/com/samitha/rn/timezone/TimezoneModuleImpl.java +0 -60
- package/android/src/main/java/com/samitha/rn/timezone/TimezonePackage.java +0 -45
- package/android/src/newarch/TimezoneModule.java +0 -9
- package/android/src/oldarch/TimezoneModule.java +0 -39
- package/lib/commonjs/index.d.js +0 -6
- package/lib/commonjs/index.d.js.map +0 -1
- package/lib/module/index.d.js +0 -2
- package/lib/module/index.d.js.map +0 -1
- package/lib/typescript/src/NativeTimezone.d.ts +0 -9
- package/lib/typescript/src/NativeTimezone.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -8
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/src/index.d.ts +0 -8
|
@@ -11,34 +11,32 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios =>
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
15
|
s.source = { :git => "https://github.com/samitha9125/react-native-timezone.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
s.frameworks
|
|
19
|
-
|
|
20
|
-
s.source_files = "ios/**/*.{h,m,mm}"
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
18
|
+
s.ios.frameworks = ['CoreTelephony']
|
|
21
19
|
|
|
22
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
23
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
24
22
|
if respond_to?(:install_modules_dependencies, true)
|
|
25
23
|
install_modules_dependencies(s)
|
|
26
24
|
else
|
|
27
|
-
|
|
25
|
+
s.dependency "React-Core"
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
end
|
|
27
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
28
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
29
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
32
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
s.dependency "React-Codegen"
|
|
36
|
+
s.dependency "RCT-Folly"
|
|
37
|
+
s.dependency "RCTRequired"
|
|
38
|
+
s.dependency "RCTTypeSafety"
|
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
44
42
|
end
|
package/src/NativeTimezone.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { TurboModule } from 'react-native';
|
|
|
2
2
|
import { TurboModuleRegistry } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export interface Spec extends TurboModule {
|
|
5
|
-
getTimeZone(): string;
|
|
6
|
-
getRegionByLocale(): string;
|
|
7
|
-
getRegionByTelephony(): string;
|
|
5
|
+
getTimeZone(): string | null;
|
|
6
|
+
getRegionByLocale(): string | null;
|
|
7
|
+
getRegionByTelephony(): string | null;
|
|
8
|
+
isAutoTimeZoneEnabled(): boolean | null;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export default TurboModuleRegistry.getEnforcing<Spec>('Timezone');
|
package/src/index.tsx
CHANGED
|
@@ -1,36 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`The package 'react-native-timezone' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
-
'- You rebuilt the app after installing the package\n' +
|
|
7
|
-
'- You are not using Expo Go\n';
|
|
8
|
-
|
|
9
|
-
// @ts-expect-error
|
|
10
|
-
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
11
|
-
const TimezoneModule = isTurboModuleEnabled
|
|
12
|
-
? require('./NativeTimezone').default
|
|
13
|
-
: NativeModules.Timezone;
|
|
14
|
-
|
|
15
|
-
const Timezone = TimezoneModule
|
|
16
|
-
? TimezoneModule
|
|
17
|
-
: new Proxy(
|
|
18
|
-
{},
|
|
19
|
-
{
|
|
20
|
-
get() {
|
|
21
|
-
throw new Error(LINKING_ERROR);
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
);
|
|
3
|
+
import Timezone from './NativeTimezone';
|
|
25
4
|
|
|
26
5
|
export default {
|
|
27
6
|
getTimeZone: () => Timezone.getTimeZone(),
|
|
28
7
|
getRegionByLocale: () => Timezone.getRegionByLocale(),
|
|
29
|
-
getRegionByTelephony: () => Timezone.getRegionByTelephony()
|
|
8
|
+
getRegionByTelephony: () => Timezone.getRegionByTelephony(),
|
|
30
9
|
isAutoTimeZoneEnabled: () => {
|
|
31
10
|
if (Platform.OS === 'android') {
|
|
32
11
|
return Timezone.isAutoTimeZoneEnabled();
|
|
33
12
|
}
|
|
34
|
-
return
|
|
13
|
+
return null;
|
|
35
14
|
},
|
|
36
15
|
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
package com.samitha.rn.timezone;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
import android.os.Build;
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.bridge.Promise;
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
8
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
-
|
|
10
|
-
import java.util.TimeZone;
|
|
11
|
-
import java.util.Calendar;
|
|
12
|
-
import android.telephony.TelephonyManager;
|
|
13
|
-
|
|
14
|
-
import android.provider.Settings;
|
|
15
|
-
import android.content.ContentResolver;
|
|
16
|
-
import android.util.Log;
|
|
17
|
-
|
|
18
|
-
public class TimezoneModuleImpl {
|
|
19
|
-
public static final String NAME = "Timezone";
|
|
20
|
-
|
|
21
|
-
// Whether the device is set to automatically detect the time zone.
|
|
22
|
-
@ReactMethod
|
|
23
|
-
public static boolean isAutoTimeZoneEnabled(ReactApplicationContext reactContext) {
|
|
24
|
-
ContentResolver resolver = reactContext.getContentResolver();
|
|
25
|
-
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
|
|
26
|
-
? Settings.Global.getInt(resolver, Settings.Global.AUTO_TIME_ZONE, 0)
|
|
27
|
-
: Settings.System.getInt(resolver, Settings.System.AUTO_TIME_ZONE, 0)) != 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@ReactMethod
|
|
31
|
-
public static String getTimeZone() {
|
|
32
|
-
try {
|
|
33
|
-
Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
|
|
34
|
-
TimeZone zone = calendar.getTimeZone();
|
|
35
|
-
return zone.getID();
|
|
36
|
-
}catch (Exception e){
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@ReactMethod
|
|
42
|
-
public static String getRegionByTelephony(ReactApplicationContext reactContext) {
|
|
43
|
-
try {
|
|
44
|
-
TelephonyManager tm = (TelephonyManager)reactContext.getSystemService(reactContext.TELEPHONY_SERVICE);
|
|
45
|
-
return tm.getNetworkCountryIso();
|
|
46
|
-
}catch (Exception e){
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@ReactMethod
|
|
53
|
-
public static String getRegionByLocale(ReactApplicationContext reactContext) {
|
|
54
|
-
try {
|
|
55
|
-
return reactContext.getResources().getConfiguration().locale.getCountry();
|
|
56
|
-
}catch (Exception e){
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
package com.samitha.rn.timezone;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.Nullable;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.NativeModule;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.module.model.ReactModuleInfo;
|
|
8
|
-
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
9
|
-
import com.facebook.react.TurboReactPackage;
|
|
10
|
-
|
|
11
|
-
import java.util.HashMap;
|
|
12
|
-
import java.util.Map;
|
|
13
|
-
|
|
14
|
-
public class TimezonePackage extends TurboReactPackage {
|
|
15
|
-
|
|
16
|
-
@Nullable
|
|
17
|
-
@Override
|
|
18
|
-
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
|
|
19
|
-
if (name.equals(TimezoneModule.NAME)) {
|
|
20
|
-
return new TimezoneModule(reactContext);
|
|
21
|
-
} else {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@Override
|
|
27
|
-
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
28
|
-
return () -> {
|
|
29
|
-
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
30
|
-
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
31
|
-
moduleInfos.put(
|
|
32
|
-
TimezoneModule.NAME,
|
|
33
|
-
new ReactModuleInfo(
|
|
34
|
-
TimezoneModule.NAME,
|
|
35
|
-
TimezoneModule.NAME,
|
|
36
|
-
false, // canOverrideExistingModule
|
|
37
|
-
false, // needsEagerInit
|
|
38
|
-
true, // hasConstants
|
|
39
|
-
false, // isCxxModule
|
|
40
|
-
isTurboModule // isTurboModule
|
|
41
|
-
));
|
|
42
|
-
return moduleInfos;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
package com.samitha.rn.timezone;
|
|
2
|
-
|
|
3
|
-
import androidx.annotation.NonNull;
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
7
|
-
import com.facebook.react.bridge.ReactMethod;
|
|
8
|
-
import com.facebook.react.module.annotations.ReactModule;
|
|
9
|
-
|
|
10
|
-
public class TimezoneModule extends ReactContextBaseJavaModule {
|
|
11
|
-
public static final String NAME = TimezoneModuleImpl.NAME;
|
|
12
|
-
|
|
13
|
-
TimezoneModule(ReactApplicationContext context) {
|
|
14
|
-
super(context);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@Override
|
|
18
|
-
@NonNull
|
|
19
|
-
public String getName() {
|
|
20
|
-
return TimezoneModuleImpl.NAME;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
24
|
-
public boolean isAutoTimeZoneEnabled() {
|
|
25
|
-
return TimezoneModuleImpl.isAutoTimeZoneEnabled(getReactApplicationContext());
|
|
26
|
-
}
|
|
27
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
28
|
-
public String getTimeZone() {
|
|
29
|
-
return TimezoneModuleImpl.getTimeZone();
|
|
30
|
-
}
|
|
31
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
32
|
-
public String getRegionByTelephony() {
|
|
33
|
-
return TimezoneModuleImpl.getRegionByTelephony(getReactApplicationContext());
|
|
34
|
-
}
|
|
35
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
36
|
-
public String getRegionByLocale() {
|
|
37
|
-
return TimezoneModuleImpl.getRegionByLocale(getReactApplicationContext());
|
|
38
|
-
}
|
|
39
|
-
}
|
package/lib/commonjs/index.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.d.ts"],"mappings":""}
|
package/lib/module/index.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.d.ts"],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TurboModule } from 'react-native';
|
|
2
|
-
export interface Spec extends TurboModule {
|
|
3
|
-
getTimeZone(): string;
|
|
4
|
-
getRegionByLocale(): string;
|
|
5
|
-
getRegionByTelephony(): string;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: Spec;
|
|
8
|
-
export default _default;
|
|
9
|
-
//# sourceMappingURL=NativeTimezone.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeTimezone.d.ts","sourceRoot":"","sources":["../../../src/NativeTimezone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,WAAW,IAAI,MAAM,CAAC;IACtB,iBAAiB,IAAI,MAAM,CAAC;IAC5B,oBAAoB,IAAI,MAAM,CAAC;CAChC;;AAED,wBAAkE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":";;;;;;AAyBA,wBAUE"}
|