dart_date 0.0.9

dart_date #

Changelog #

0.0.9 #

  • Changes Date.parse to accept or not a format
  • Added date.isFirstDayOfMonth getter
  • Added date.isLastDayOfMonth getter
  • Added date.isLeapYear getter

0.0.8 #

  • Adding documentation and timeago date.timeago()

example/dart_date_example.dart

import 'package:dart_date/dart_date.dart';

main(List<String> args) {
  const pattern = "'Heute ist' dd-MMMM-yyyy";
  final n = Date.now();
  final d = Date.now().format(pattern, "de_DE");
  final x = Date.parse(d, pattern: pattern, locale: "de_DE");
  print("$d ($x)"); // Heute ist 30-November-2018 (2018-11-30 00:00:00.000)

  // ES language is pre-configured;
  print(Date.now().subDays(100).timeago(locale: 'es')); // hace 3 meses
  print(Date.now().format('MMMM dd y, h:mm:ss a')); // November 30 2018, 9:14:29 PM
  print(Date(2006, 6, 6, 6, 6, 6, 6, 6)); // 2006-06-06 06:06:06.006006 // UTC-5
  print(Date(2006, 6, 6, 6, 6, 6, 6, 6).UTC); // 2006-06-06 11:06:06.006006Z // UTC
  var now = Date.now(); // 2018-11-30 21:25:21.092647
  var closest = now.closestTo([ //2018-11-28 21:25:21.025275
    n.nextWeek,
    n.previousDay.previousDay,
    n.previousWeek.nextDay,
    n.nextMonth,
    //n.nextDay,
    //n,
    n.nextYear
  ]);
  print("Closest to now ($now): $closest (${closest.timeago()})");
  // Closest to now (2018-11-30 21:25:21.092647): 2018-11-28 21:25:21.025275 (2 days ago)
  print(Date.today is DateTime);

  print(Date.parse("2014-11-20T16:51:30.000Z").toHumanString());
}

Use this package as a library

1. Depend on it

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


dependencies:
  dart_date: ^0.0.9

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:dart_date/dart_date.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
84
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Aug 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Fix lib/src/dart_date.dart. (-16.09 points)

Analysis of lib/src/dart_date.dart reported 35 hints, including:

line 159 col 18: Use = to separate a named parameter from its default value.

line 168 col 18: Use = to separate a named parameter from its default value.

line 177 col 18: Use = to separate a named parameter from its default value.

line 205 col 5: Don't explicitly initialize variables to null.

line 344 col 8: Use isEmpty instead of length

Format lib/dart_date.dart.

Run dartfmt to format lib/dart_date.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
intl ^0.15.7 0.15.8
timeago ^2.0.9 2.0.18
Transitive dependencies
path 1.6.4
Dev dependencies
test ^1.3.0