https://github.com/sleeplessbyte/react-native-time-helpers
Time helpers for consistency across platforms when using react-native, for en-GB locale
https://github.com/sleeplessbyte/react-native-time-helpers
Last synced: 9 months ago
JSON representation
Time helpers for consistency across platforms when using react-native, for en-GB locale
- Host: GitHub
- URL: https://github.com/sleeplessbyte/react-native-time-helpers
- Owner: SleeplessByte
- License: mit
- Created: 2020-05-22T21:16:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T04:41:52.000Z (over 3 years ago)
- Last Synced: 2024-10-18T19:47:40.927Z (over 1 year ago)
- Language: TypeScript
- Size: 421 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-time-helpers
This package aims to provide date helpers for Android, where `.toLocaleDateXXX` don't (always) work as expected.
It's in no way a replacement for a full-fledged date/time library, and it currently only has defaults for English.
However, if your project is in a single language, and you don't need timezone support (display cross timezones), this will work just fine.
## Installation
```bash
yarn add react-native-time-helpers
```
Even though this package is _meant_ for the `react-native` ecosystem, it has bundles for CJS, ES, UMD, and modern browsers.
## Usage
`toLocaleDateString` has the following helpers:
- `localeLongWeekDayString(date)`: return the weekday name of the date
- `localeWeekDayString(date)`: return the weekday name (short) of the date
- `localeDateString(date)`: return the date as `{weekday} {day} {month} {year}`
- `localeTimeString(date)`: return the time as `{hh}:{mm}` (24h)
Each helper has optional options to override or change behaviour.