dart_date 1.3.2 copy "dart_date: ^1.3.2" to clipboard
dart_date: ^1.3.2 copied to clipboard

Date manipulation library. DateTime extensions. Also includes an Interval object.

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 = DateTime.now();
  final de_String = DateTime.now().format(pattern, 'de_DE');
  final de_Date = Date.parse(de_String, pattern: pattern, locale: 'de_DE');
  print(
    'DE (String): $de_String',
  );
  print(
    'DE (Date): $de_Date',
  );

  final es_Timeago = DateTime.now().subDays(100).timeago(locale: 'es');
  print("ES (Timeago): $es_Timeago");

  final en_Format = DateTime.now().format('MMMM dd y, h:mm:ss a');
  print("EN (Format): $en_Format");

  final utc = DateTime(2006, 6, 6, 6, 6, 6, 6, 6).utc;
  print(".UTC: $utc");

  var now = DateTime.now();
  var closest = now.closestTo(
    [
      n.nextWeek,
      n.previousDay.previousDay,
      n.previousWeek.nextDay,
      n.nextMonth,
      n.nextYear,
    ],
  )!;
  print('Closest to now ($now): $closest (${closest.timeago()})');

  print(Date.today is DateTime);

  print("Human String: " +
      DateTime.parse('2014-11-20T16:51:30.000Z').toHumanString());

  print("Yesterday: " + (Date.today - Duration(days: 1)).toString());
  print("Tomorrow: " + (Date.today + Duration(days: 1)).toString());

  print(Duration(days: 1) + Duration(hours: 12, minutes: 5));
  print(Duration(days: 1) - Duration(hours: 12, minutes: 5));
  print(Duration(hours: 1) * 2.5);
  print(Duration(hours: 1) / 70);
}
156
likes
130
pub points
96%
popularity

Publisher

verified publisherxantiagoma.com

Date manipulation library. DateTime extensions. Also includes an Interval object.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

intl, timeago

More

Packages that depend on dart_date