date_generator 1.0.0 copy "date_generator: ^1.0.0" to clipboard
date_generator: ^1.0.0 copied to clipboard

Generate dates based on their position within a month

example/date_generator_example.dart

import 'package:date_generator/dart_date_generator.dart';

void main() {
  var gen = Generator();

  var res = gen.first.sunday.january.of(2020);
  print(res);
  res = gen.second.thursday.march.of(1900);
  print(res);

  // Equivalents
  res = gen.last.monday.december.of(2021);
  var same = gen.week(5).monday.december.of(2021);
  var othersame = gen.week(5).weekDay(2).december.of(2021);
  var yetanothersame = gen.week(5).weekDay(2).month(12).of(2021);
  print(res.toIso8601String() == same.toIso8601String() &&
      same.toIso8601String() == othersame.toIso8601String() &&
      othersame.toIso8601String() == yetanothersame.toIso8601String());

  res = gen.last.monday.december.of(2021);
  same = gen.last.monday.month(12).of(2021);
  print(res.toIso8601String() == same.toIso8601String());

  res = gen.last.monday.december.of(2021);
  same = gen.week(5).monday.month(12).of(2021);
  print(res.toIso8601String() == same.toIso8601String());

  res = gen.second.weekDay(2).december.of(2021);
  same = gen.week(2).monday.month(12).of(2021);
  print(res.toIso8601String() == same.toIso8601String());
}
5
likes
140
pub points
19%
popularity

Publisher

verified publisherpetit.dev

Generate dates based on their position within a month

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on date_generator