Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-native-timezone
Advanced tools
Readme
A Simple react native module to get the Timezone and the Region of the Android/iOS devices.
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.
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 version | Tested | Result |
---|---|---|
0.62.3 + | ✅ | ✅ |
0.70.0 + | ✅ | ✅ |
0.73.0 + | ✅ | ✅ |
npm i react-native-timezone
Do cd ios/ && pod install
or npx pod-install
.
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.
API | Description |
---|---|
getTimeZone | Android: Returns timezone ID using java.util.TimeZone.getID() iOS: Reflects the current system time zone using localTimeZone of NSTimeZone |
isAutoTimeZoneEnabled | Returns a boolean indicating if auto timezone is enabled on the device (Android Only) |
getRegionByTelephony | Retrieves the region information based on the telephony (SIM card) of the device. Returns undefined if the device has no SIM card. |
getRegionByLocale | Retrieves the region information based on the device's locale settings |
FAQs
A Simple react native module to get Timezone and Region of the Android/iOS devices.
The npm package react-native-timezone receives a total of 1,748 weekly downloads. As such, react-native-timezone popularity was classified as popular.
We found that react-native-timezone demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.