https://github.com/robertherber/clock-format-utility
A tiny library for 12/24 hour clock formatting. The main use-case is to support non-standard language/localization combinations - specifically in moment.
https://github.com/robertherber/clock-format-utility
24hour clock javascript react-native
Last synced: over 1 year ago
JSON representation
A tiny library for 12/24 hour clock formatting. The main use-case is to support non-standard language/localization combinations - specifically in moment.
- Host: GitHub
- URL: https://github.com/robertherber/clock-format-utility
- Owner: robertherber
- Created: 2017-07-03T18:54:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-16T17:21:40.000Z (almost 9 years ago)
- Last Synced: 2025-02-28T12:25:03.987Z (over 1 year ago)
- Topics: 24hour, clock, javascript, react-native
- Language: JavaScript
- Homepage:
- Size: 90.8 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# clock-format-utility
[ ](https://app.codeship.com/projects/245786)
This is a tiny library used to set 12/24 hour clock formatting.
The main use-case is to **support non-standard language/localization combinations** - specifically in moment.
It exposes the following methods; two detection methods:
- **detectDeviceClockFormat**
- by parsing `date.toLocaleString(detectedDeviceLocale)`
- **detectDeviceLocale**
- using `react-native-device-info` or (if not available) `navigator.language`
And two specifically aimed at configuring moment:
- **setMomentLocaleClockFormat**
- overrides current moment locale clock format with detected device clock format
- **setMomentLocale**
- sets `moment.locale` to the detected device locale
Please feel free to submit pull-requests for other libraries (`detectDeviceLocale` could benefit from supporting more libraries than `react-native-device-info`, and setters for `date-fns` would be very welcome)