humanize 0.3.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

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 #

[0.3.0] - 18 Jun 2020. #

  • Fix Ordinal Translating 81 as 81th
  • Fix Ordinal Translating 1 as 1th and 2 as 2th

[0.2.1] - 21 February 2020. #

  • appropriate file

[0.2.0] - 13 February 2020. #

  • Add MIT Licence

  • Documentation on README.md file

[0.1.0] - 13 February 2020. #

  • ordinal

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

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

example/main.dart

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

void main() {
  print(humanize.appNumber(1)); // one
  print(humanize.appNumber(9)); // six
  print(humanize.intComma(100));
  print(humanize.intComma(80010000));
  print(humanize.ordinal(1)); // 2nd
  print(humanize.ordinal(2)); // 2nd
  print(humanize.ordinal(11));
  print(humanize.ordinal(81)); // 24th
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  humanize: ^0.3.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:humanize/humanize.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
68
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • humanize that is a package requiring null.

Health suggestions

Fix lib/src/humanize.dart. (-0.50 points)

Analysis of lib/src/humanize.dart reported 1 hint:

line 78 col 8: This function has a return type of 'String', but doesn't end with a return statement.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test