simple_moment 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 80

simple_moment Pub Build Status

A simple implementation of the Moment.js features for relative time in Dart.

Usage

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));
}

Locales

Set the locale for all usages of Moment:

Moment.setLocaleGlobally(new LocaleDe());

Set the locale only for the current instance of Moment:

var moment = new Moment.now().locale(new LocaleDe());

Adding your own locale:

Just create a class that implements ILocaleData 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.

Changelog

1.0.2

  • added pt_BR locale (#3)

1.0.1

  • make pub analyzer happy

1.0.0

  • upgraded to Dart SDK 2.0

0.1.1

  • added missing export for IdentifierPosition

0.1.0

  • added locale functionality (#2)

0.0.3

  • fixed bug for diff under one second (#1)

0.0.2

  • fixed a few bugs
  • better rounding

0.0.1

  • Initial version

example/simple_moment_example.dart

// Copyright (c) 2016, rinukkusu. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

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));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  simple_moment: ^1.0.2

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:simple_moment/simple_moment.dart';
  
Version Uploaded Documentation Archive
1.0.2 Nov 27, 2018 Go to the documentation of simple_moment 1.0.2 Download simple_moment 1.0.2 archive
1.0.1 Nov 21, 2018 Go to the documentation of simple_moment 1.0.1 Download simple_moment 1.0.1 archive
1.0.0 Oct 31, 2018 Go to the documentation of simple_moment 1.0.0 Download simple_moment 1.0.0 archive
0.1.1 Jun 22, 2018 Go to the documentation of simple_moment 0.1.1 Download simple_moment 0.1.1 archive
0.1.0 Jun 22, 2018 Go to the documentation of simple_moment 0.1.0 Download simple_moment 0.1.0 archive
0.0.3 May 14, 2018 Go to the documentation of simple_moment 0.0.3 Download simple_moment 0.0.3 archive
0.0.2 Dec 31, 2016 Go to the documentation of simple_moment 0.0.2 Download simple_moment 0.0.2 archive
0.0.1 Dec 31, 2016 Go to the documentation of simple_moment 0.0.1 Download simple_moment 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
67
Health:
Code health derived from static analysis. [more]
90
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
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:simple_moment/simple_moment.dart.

Health issues and suggestions

Document public APIs (-10 points)

95 out of 95 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.0