date_format 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 47

date_format

A simple API to format dates.

Usage

Use formatDate function to format a DateTime

print(formatDate(new DateTime(1989, 02, 21), [yyyy, '-', mm, '-', dd]));

Output:

1989-02-21

Long month names

print(formatDate(new DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

Output:

89-feb-21

Time parts

print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

Output:

15:40:10

Timezone

print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

Output:

15:40:10+0100

Changelog

1.0.2

  • Fixed negative timezone bug

1.0.1

  • Docs
  • Added microsecond

1.0.0

  • formatDate

example/date_format_example.dart

import 'package:date_format/date_format.dart';

main() {
  print(formatDate(new DateTime(1989, 2, 21), [yyyy, '-', mm, '-', dd]));
  print(formatDate(new DateTime(1989, 2, 21), [yy, '-', m, '-', dd]));
  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', m, '-', d]));

  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', MM, '-', d]));
  print(formatDate(new DateTime(1989, 2, 21), [yy, '-', M, '-', d]));

  print(formatDate(new DateTime(1989, 2, 1), [yy, '-', M, '-', d]));

  print(formatDate(new DateTime(2018, 1, 14), [yy, '-', M, '-', DD]));
  print(formatDate(new DateTime(2018, 1, 14), [yy, '-', M, '-', D]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [hh, ':', nn, ':', ss, ' ', am]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [hh, ':', nn, ':', ss, ' ', am]));

  print(formatDate(new DateTime(1989, 02, 1, 15, 40, 10), [hh]));
  print(formatDate(new DateTime(1989, 02, 1, 15, 40, 10), [h]));

  print(formatDate(new DateTime(1989, 02, 1, 5), [am]));
  print(formatDate(new DateTime(1989, 02, 1, 15), [am]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, z]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, ' ', Z]));

  print(formatDate(new DateTime(1989, 02, 21), [yy, ' ', w]));
  print(formatDate(new DateTime(1989, 02, 21), [yy, ' ', W]));

  print(formatDate(new DateTime(1989, 12, 31), [yy, '-W', W]));
  print(formatDate(new DateTime(1989, 1, 1), [yy, '-', mm, '-w', W]));

  print(formatDate(
      new DateTime(1989, 02, 1, 15, 40, 10), [HH, ':', nn, ':', ss, ' ', Z]));
}

Use this package as a library

1. Depend on it

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


dependencies:
  date_format: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_format/date_format.dart';
  
Version Uploaded Documentation Archive
1.0.5 Aug 7, 2018 Go to the documentation of date_format 1.0.5 Download date_format 1.0.5 archive
1.0.4 Jan 25, 2018 Go to the documentation of date_format 1.0.4 Download date_format 1.0.4 archive
1.0.2 Jan 14, 2018 Go to the documentation of date_format 1.0.2 Download date_format 1.0.2 archive
1.0.1 Jan 14, 2018 Go to the documentation of date_format 1.0.1 Download date_format 1.0.1 archive
1.0.0 Jan 14, 2018 Go to the documentation of date_format 1.0.0 Download date_format 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0