Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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 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)