An implementation of some Moment.js features for parsing, manipulates and displaying dates in Dart.
A simple usage example:
import 'package:tempus/tempus.dart';
main() {
Duration secondsToAdd = new Duration(seconds: 10);
DateTime dateForComparison = new DateTime.now().add(secondsToAdd);
Tempus tempus = new Tempus();
// Will print "in a few seconds"
print(tempus.from(Tempus.fromDate(dateForComparison)));
// Will generate a list with 35 DateTimes, perfect for creating
// calendar grids. By default starts on Sunday, can be Monday.
DateTime randomDate = new DateTime(2018, 10);
List<DateTime> dateGrid = Tempus.daysInMonth(randomDate, startOnMonday: true);
}
Tempus.globalLocale(new LocaleDE());
Tempus tempus = new Tempus.now().locale(new LocaleDE());
Just create a class that implements ILocale
and assign that to your Tempus
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.
This package draws inspiration and code from rinukkusu/simple_moment and apptreesoftware/date_utils.