Giter Site home page Giter Site logo

software-mansion-labs / react-native-hour-format Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 5.0 19 KB

Get hour format from OS settings.

License: MIT License

Java 43.47% JavaScript 6.31% Objective-C 26.79% Ruby 23.44%
react-native momentjs moment hour format pm am 24hour 24

react-native-hour-format's Introduction

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'
	}
});

react-native-hour-format's People

Contributors

mironiasty avatar tsapeta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-hour-format's Issues

Date format?

Is it possible to get date format from system? Like if it should me month / day / year or day / month / year etc.

RNHourFormat requires main queue setup

Hi,
on iOS in RN 51 console show this warning :

Module RNHourFormat requires main queue setup since it overrides constantsToExport but doesn't implement requiresMainQueueSetup. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.

broken podspec

arnif@33c63cb fixes the following build error:

node_modules/react-native-hour-format/ios/RNHourFormat.h:8:9: 'React/RCTBridgeModule.h' file not found

...by adding a podspec dependency on React, but puts the podspec in the wrong place. It should be in the top-level directory, not the ios/ directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.