dart_date 1.5.3 copy "dart_date: ^1.5.3" to clipboard
dart_date: ^1.5.3 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 =
      DateTimeExtension.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(DateTimeExtension.today is DateTime);

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

  print(
      "Yesterday: " + (DateTimeExtension.today - Duration(days: 1)).toString());
  print(
      "Tomorrow: " + (DateTimeExtension.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);
}
186
likes
160
points
26.5k
downloads

Publisher

verified publisherxantiagoma.com

Weekly Downloads

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

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

intl, timeago

More

Packages that depend on dart_date