Giter Site home page Giter Site logo

humanize's Introduction

humanize

A package for translating numbers and dates into a human readable format.

Pub

Usage

import 'package:humanize/humanize.dart' as humanize;

main(){
    print(humanize.appNumber(1)); // one
    print(humanize.ordinal(3)); // 3rd
}

Function

appNumber

For numbers 1-9, return the number spelled out. Otherwise, return the number.

import 'package:humanize/humanize.dart' as humanize;

main(){
    print(humanize.appNumber(1)); // one
    print(humanize.appNumber(5)); // five
    print(humanize.appNumber(15)); // '15'
}

ordinal

Convert an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. works for any integer.

import 'package:humanize/humanize.dart' as humanize;

main(){
    print(humanize.ordinal(80)); // 80th
    print(humanize.ordinal(81)); // 81st /// except 11.
    print(humanize.ordinal(82)); // 82nd /// except 12.
    print(humanize.ordinal(83)); // 81rd /// except 13.
    print(humanize.ordinal(84)); // 84th    
}

intComma

Convert an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'.

import 'package:humanize/humanize.dart' as humanize;

main(){
    print(humanize.intComma(80010000)); //80,010,000
}

TODO

intWord

Convert a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.

naturalDay

For date values that are tomorrow, today or yesterday compared to present day return representing string. Otherwise, return a string formatted according to DATE_FORMAT.

naturalTime

For date and time values show how many seconds, minutes, or hours ago compared to current timestamp return representing string.

Features and bugs

Please file feature requests and bugs at the issue tracker.

V2.0 (dev Branch)

Adding differents Languages

humanize's People

Contributors

jeanluc243 avatar lucdotdev avatar olindenbaum avatar

Stargazers

 avatar

Watchers

 avatar

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.