Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 10 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-16T17:21:40.000Z (about 7 years ago)
- Last Synced: 2024-10-11T01:59:47.751Z (26 days 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
[ ![Codeship Status for robertherber/clock-format-utility](https://app.codeship.com/projects/78dc88f0-7cf6-0135-5c44-361f0802280c/status?branch=master)](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 localePlease 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)