better_moment Build Status

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


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"


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.


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