Coder Social home page Coder Social logo

sergeymild / react-native-formatter Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 429 KB

React Native JSI date/currency formatter

License: MIT License

CMake 1.78% C++ 57.20% C 1.11% Java 18.43% JavaScript 1.24% Ruby 1.96% Makefile 1.16% TypeScript 3.07% Swift 0.05% Objective-C 1.18% Objective-C++ 12.83%
currency-formatter dateformatter jsi react-native reactnative currencyformatter

react-native-formatter's Introduction

React Native JSI date formatter

Format date on Native Side

Installation

"react-native-formatter": "sergeymild/react-native-formatter#0.17.0"

Usage

import { formatter } from 'react-native-date-formatter';

// ...
export interface Locale {
  // language code of locale
  code: string;
  // translated on original locale name
  displayName: string;
  // translated on current locale name
  name: string;
  // need pass to native for change locale
  changeCode: string;
}

// represents date like in telegram chats
// for example if date is today it will returns `time`
// for example if date in current week it will returns `name of week`
// or yyyy.mm.dd formatted for certain locale
// accepts date in mills or string `YYYY-MM-DDTHH:mm:ss.sssZ` format
formatter.date.chatLikeFormat(Date.now())
// return HH:mm of h:mm a if is 24 hours enabled on phone
// accepts date in mills or string `YYYY-MM-DDTHH:mm:ss.sssZ` format
formatter.date.hoursMinutes(Date.now())
// just format date with passed pattern
// accepts date in mills or string `YYYY-MM-DDTHH:mm:ss.sssZ` format
formatter.date.format(Date.now(), 'dd MMM yyyy HH:mm')
//Short will return "12/13/52"
formatter.date.simpleFormat(Date.now())
// formatting of a relative date or time, such as "in 2 weeks", "in 3 months"
// accepts date in mills or string `YYYY-MM-DDTHH:mm:ss.sssZ` format
formatter.date.fromNow(futureTime)
// returns date string formatted as ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ)
formatter.date.toISO8601format(date: number): string
// change current locale true - if success false otherwise
formatter.locale.setNew(locale: string): boolean;
// get current locales
formatter.locale.getCurrent(): Locale;
// get all available locales (performance consuming operations might need to cache)
formatter.locale.allAvailable(): Locale[];

// format value to current locale currency
// for example 12934.4348943 will be formatted to $12,934.43
formatter.currency.format(12934.4348943, symbol?: string)

For android needs add to Proguard

-keep class org.ocpsoft.prettytime.i18n.**

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

react-native-formatter's People

Contributors

sergeymild avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

oneclick-llc

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.