tempus 0.2.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • new58

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.2.0] - 2018-11-17

  • Added weekday lists to all locales

[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:
  tempus: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:tempus/tempus.dart';
  
Version Uploaded Documentation Archive
0.2.0 Nov 17, 2018 Go to the documentation of tempus 0.2.0 Download tempus 0.2.0 archive
0.1.0 Nov 14, 2018 Go to the documentation of tempus 0.1.0 Download tempus 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
20
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:tempus/tempus.dart.

Health suggestions

Format lib/src/locale/locales.dart.

Run dartfmt to format lib/src/locale/locales.dart.

Format lib/src/locale/locales/de.dart.

Run dartfmt to format lib/src/locale/locales/de.dart.

Format lib/src/locale/locales/es.dart.

Run dartfmt to format lib/src/locale/locales/es.dart.

Format lib/src/locale/locales/pt.dart.

Run dartfmt to format lib/src/locale/locales/pt.dart.

Format lib/src/tempus.dart.

Run dartfmt to format lib/src/tempus.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use tempus.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
intl ^0.15.0 0.15.7
Transitive dependencies
path 1.6.2
Dev dependencies
test ^1.5.0