better_moment 0.1.0

  • Readme
  • Changelog
  • Installing
  • 17

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 DateTime.now().add(secondsToAdd);
    Moment moment = new Moment.now();

    // should print "in a few seconds"
    print(moment.from(dateForComparison));
}

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 Moment.now().locale(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:


dependencies:
  better_moment: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

This package is not analyzed, because it is discontinued.

Dependencies

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