date_calc 0.1.1+3 copy "date_calc: ^0.1.1+3" to clipboard
date_calc: ^0.1.1+3 copied to clipboard

Date manipulation library for Dart. It provides a class that inherits from the DateTime class, makes it easy to calculate additions, subtractions and so on.

date_calc #

Date manipulation library for easy calculating.

Usage #

Installation #

Add date_calc as a dependency in pubspec.yaml file.

dependencies:
  date_calc: ^0.1.0

Run pub install.

Using #

import 'package:date_calc/date_calc.dart';

final date = DateCalc(2019, 1, 5);
print(date.addMonth(1));
// => 2019-02-05 00:00:00.000
print(date.addYear(1).isLeapYear());
// => true
print(date.addYear(1).addMonth(1).daysInMonth());
// => 29
print(date.dup(minute: 11));
// => 2019-01-05 00:11:00.000
print(date.differenceValue(date: DateTime(2019, 3, 3), type: DateType.month));
// => 1
print(DateCalc.now().isToday());
// => true

Because DateCalc is a subclass of DateTime, you can use all DateTime methods.
When you need exactly DateTime object, use toDate() method.

final date = DateCalc(2019, 1, 5);
date.subtractYear(1).toDate();

milestones for 1.0.0 #

  • support for DST
  • support for UTC & Timezone
  • support for leapsecond
7
likes
30
pub points
45%
popularity

Publisher

unverified uploader

Date manipulation library for Dart. It provides a class that inherits from the DateTime class, makes it easy to calculate additions, subtractions and so on.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

intl, meta

More

Packages that depend on date_calc