date_format 1.0.5

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

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.4

  • Capital letters

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.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:date_format/date_format.dart.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.0