A simple implementation of the Moment.js features for relative time in Dart.
A simple usage example:
import 'package:simple_moment/simple_moment.dart';
main() {
var secondsToAdd = new Duration(seconds: 10);
var dateForComparison = new DateTime.now().add(secondsToAdd);
var moment = new Moment.now();
// should print "in a few seconds"
print(moment.from(dateForComparison));
}
Moment.setLocaleGlobally(new LocaleDe());
var moment = new Moment.now().locale(new LocaleDe());
Just create a class that implements ILocaleData
and assign that to your Moment
instance or set it globally.
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';
}
Please file feature requests and bugs at the issue tracker.