tempus 0.2.0 copy "tempus: ^0.2.0" to clipboard
tempus: ^0.2.0 copied to clipboard

outdated

Handy tools for parsing, manipulating and displaying DateTimes in Dart.

tempus Pub Build Status #

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

Usage #

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(dateForComparison));

    DateTime randomDate = new DateTime(2018, 10);
    // Will generate a list with 42 DateTimes, perfect for creating
    // calendar grids. By default starts on Sunday, can be Monday.
    List<DateTime> dateGrid = Tempus.datesInMonthGrid(randomDate, true);
}

Locales #

Set the locale for all usages of Tempus: #

Tempus.globalLocale(new LocaleDE());

Set the locale only for the current instance of Tempus: #

Tempus tempus = new Tempus.now().locale(new LocaleDE());

Adding your own locale: #

Just create a class that implements ILocale and assign that to your Tempus 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_tempus and apptreesoftware/date_utils.

0
likes
0
pub points
0%
popularity

Publisher

verified publisherlucasvienna.dev

Handy tools for parsing, manipulating and displaying DateTimes in Dart.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

intl

More

Packages that depend on tempus