You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-native-timezone

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-timezone

A Simple react native module to get Timezone and Region of the Android/iOS devices.

3.1.0
latest
Source
npmnpm
Version published
Weekly downloads
1.9K
12.51%
Maintainers
0
Weekly downloads
 
Created
Source

React Native Timezone and Region

Maintainability

A Simple react native module to get the Timezone and the Region of the Android/iOS devices.

Motivation

For a project of mine, I had to acquire the currently selected timezone of the user. Unfortunately, I could not find any react native package or react native in-build function that facilitates this. Thus I created a small library.

v3.0.0 and above, you can access the Region details. More details can be found below.

Compatibility

Timezone version 3.0.0 only supports React Native version 0.62.3 and above due to the React Native Regular Expression Denial of Service (ReDoS) vulnerability.

React native versionTestedResult
0.70.0 +
0.73.0 +
0.76.5 +

Installation

npm i react-native-timezone

iOS

Do cd ios/ && pod install or npx pod-install.

Usage

import TimeZone from 'react-native-timezone';

export default function App() {
  React.useEffect(() => {
    const timezone = Timezone.getTimeZone();
    const isAutoTimeZoneEnabled = Timezone.isAutoTimeZoneEnabled();
    const telephonyRegion = Timezone.getRegionByTelephony();
    const localeRegion = Timezone.getRegionByLocale();
    // Update state or use data as needed
  }, []);

  // Render your component
}

Check out the example folder.

APIs

APIDescription
getTimeZoneAndroid: Returns timezone ID using java.util.TimeZone.getID()
iOS: Reflects the current system time zone using localTimeZone of NSTimeZone
isAutoTimeZoneEnabledReturns a boolean indicating if auto timezone is enabled on the device (Android Only)
getRegionByTelephonyRetrieves the region information based on the telephony (SIM card) of the device. Returns undefined if the device has no SIM card.
getRegionByLocaleRetrieves the region information based on the device's locale settings

Keywords

react-native

FAQs

Package last updated on 14 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.