date_calendar 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Dart Calendar #

A Calendar interface with a Gregorian Calendar implementation in Dart.

Treats whole days as the smallest unit of time; takes into account leap years.

Not well tested with BC dates (negative dates).

Gregorian implementation does not help you currently with historical dates of when the Gregorian calendar was adapted (e.g. if you want the local date in Denmark before the 1700s, you'll need to switch to Julian, and that's not handled here).

CHANGELOG #

0.2.1 #

  • Fix cases where adding negative days worked incorrectly.

0.2.0 #

  • Change constant names to lower case for compatibility with newer versions of Dart
  • Push minimum SDK constraint up

0.1.6 #

  • Bug fix in addDays/addMonths
  • Add unit tests for iterators, addDays

0.1.5 #

  • Add missing export

0.1.4 #

  • Make calendar iterators more generic friendly
  • Move claendar iterators to their own file

0.1.3 #

  • Bugfix for WeekdayMask.fromInteger()

0.1.2 #

  • Add class to handle weekday masks
  • Fix bad file references in test/example

0.1.1 #

  • Fix dart analysis issues (remove unused import, fix type issue on compareTo)
  • Throw error if compareTo is called with a non-Gregorian date

0.1.0 #

  • Initial publication

example/main.dart

import 'package:date_calendar/date_calendar.dart';

void main() {
  //  var d = new GregorianCalendar(2018, 14, 31);
  // var d2 = GregorianCalendar.fromInt(1210332);

  final List<GregorianCalendar> days = GregorianCalendar.getWeekdaysFromWeek(
      new GregorianCalendar(2018, 2, 24),
      new WeekdayMask.fromIterable(<int>[7, 2, 4, 5]));
  print(days);
  // print(d);
  // for (var day in new MonthIterable(
  //   new GregorianCalendar(2018, 1, 31),
  //   new GregorianCalendar(2019, 2, 25),
  //   increment: 1,
  // )) {
  //   print(day);
  // }
}

Use this package as a library

1. Depend on it

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


dependencies:
  date_calendar: ^0.2.1

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:date_calendar/date_calendar.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
72
Health:
Code health derived from static analysis. [more]
85
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Fix lib/src/gregorian_calendar.dart. (-7.24 points)

Analysis of lib/src/gregorian_calendar.dart reported 15 hints, including:

line 4 col 33: Avoid const keyword.

line 18 col 46: Avoid const keyword.

line 33 col 35: Avoid const keyword.

line 53 col 13: Unnecessary new keyword.

line 79 col 47: Unnecessary new keyword.

Fix lib/src/weekday_mask.dart. (-5.36 points)

Analysis of lib/src/weekday_mask.dart reported 11 hints, including:

line 29 col 49: Avoid const keyword.

line 40 col 49: Avoid const keyword.

line 51 col 52: Avoid const keyword.

line 120 col 14: Unnecessary new keyword.

line 126 col 12: Unnecessary new keyword.

Fix lib/src/calendar_iterators.dart. (-3.45 points)

Analysis of lib/src/calendar_iterators.dart reported 7 hints, including:

line 22 col 13: Unnecessary new keyword.

line 26 col 13: Unnecessary new keyword.

line 29 col 13: Unnecessary new keyword.

line 63 col 34: Unnecessary new keyword.

line 72 col 34: Unnecessary new keyword.

Maintenance suggestions

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

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