This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

react-native-hour-format

1.1.3 • Public • Published

react-native-hour-format

Get hour format from OS settings.

Installation

Add as dependency:

npm i --save react-native-hour-format

Link with react-native:

react-native link react-native-hour-format

Usage

There are three methods you can call:

import { HourFormat } from 'react-native-hour-format';
 
HourFormat.is24HourFormat() // bool
HourFormat.getHourFormat() // 12 or 24
HourFormat.getLocale() // string with system locale

Integration with momentjs

Use below snippet so moment().format('LT') will return correctly formated values.

import { HourFormat } from 'react-native-hour-format';
import moment from 'moment';
 
const is24HourFormat = HourFormat.is24HourFormat();
moment.updateLocale('en', {
  longDateFormat: {
    LT: is24HourFormat ? 'HH:mm' : 'hh:mm a',
    LTS: is24HourFormat ? 'HH:mm:ss' : 'hh:mm:ss a'
    }
});

Package Sidebar

Install

npm i react-native-hour-format

Weekly Downloads

174

Version

1.1.3

License

MIT

Unpacked Size

55.5 MB

Total Files

1770

Last publish

Collaborators

  • mironiasty