better_moment 0.1.0

  • Readme
  • Changelog
  • Installing
  • 76

better_moment Build Status

An implementation of some Moment.js features for parsing, manipulates and displaying dates in Dart.

Usage #

A simple usage example:

import 'package:better_moment/better_moment.dart';

main() {
    Duration secondsToAdd = new Duration(seconds: 10);
    DateTime dateForComparison = new;
    Moment moment = new;

    // should print "in a few seconds"

Locales #

Set the locale for all usages of Moment:

Moment.globalLocale(new LocaleDE());

Set the locale only for the current instance of Moment:

Moment moment = new LocaleDE());

Adding your own locale: #

Just create a class that implements ILocale and assign that to your Moment instance or set it globally.

Overwriting existing locales: #

class ShortLocaleEn extends LocaleEN {
  String get seconds => '%is';

  String get aMinute => '%im';
  String get minutes => '%im';

  String get anHour => '%ih';
  String get hours => '%ih';

  String get aDay => '%id';
  String get days => '%id';

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Credits #

This package draws inspiration and code from rinukkusu/simple_moment and apptreesoftware/date_utils.

[0.1.0] - 2018-11-12

Initial release. #

  • Added docs

Use this package as a library

1. Depend on it

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

  better_moment: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:better_moment/better_moment.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:better_moment/better_moment.dart.

Health suggestions

Fix lib/src/moment.dart. (-7.71 points)

Analysis of lib/src/moment.dart reported 16 hints, including:

line 37 col 18: Use = to separate a named parameter from its default value.

line 54 col 32: Don't explicitly initialize variables to null.

line 63 col 19: Don't explicitly initialize variables to null.

line 109 col 7: DO use curly braces for all flow control structures.

line 111 col 7: DO use curly braces for all flow control structures.

Format lib/src/locale/locale.dart.

Run dartfmt to format lib/src/locale/locale.dart.

Format lib/src/locale/locales/de.dart.

Run dartfmt to format lib/src/locale/locales/de.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/locale/locales/en.dart (Run dartfmt to format lib/src/locale/locales/en.dart.)
  • lib/src/locale/locales/es.dart (Run dartfmt to format lib/src/locale/locales/es.dart.)
  • lib/src/locale/locales/pt.dart (Run dartfmt to format lib/src/locale/locales/pt.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and better_moment.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
Dev dependencies
test ^1.5.0