vy_date 0.3.4

vy_date #

Simple utilities for managing dates and periods.

The Date class simply wraps the DateTime one. But I think it is easier to manage and to understand the logic of the program this way. license.

Usage #

A simple usage example:

import 'package:vy_date/vy_date.dart';

main() {
  Date date = Date.now();
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.3.4 #

  • Added toYMdString() and parseYMdString()

0.3.3 #

  • Sdk 2.2.0 support
  • Call to DatePeriod.isInPeriod() was giving error if the date parameter was null. Now returns false.
  • Changed the way how the DatePeriod is serialized (toJson). Instead of saving the duration, it is saved the end date in format yyyy-mm-dd
  • Added the weekday getter

0.3.2 #

  • Sdk 2.1.0 support.
  • Some Linter rules applied

0.3.1 #

  • Dart 2 support

0.3.0 #

  • Initial version

example/example.dart

// Copyright (c) 2017, Giorgio. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:intl/date_symbol_data_local.dart' show initializeDateFormatting;

import 'package:vy_date/vy_date.dart';

void main() async {
  Date date = Date.now();
  final Date nextDay = date.add(Duration(days: 1));
  final DatePeriod period = DatePeriod(date, nextDay);
  // prints: "Number of days: 2"
  print('Number of days: ${period.inDays}');
  // print "Difference in days: 1"
  print('Difference in days: ${nextDay.difference(date).inDays}');
  // prints "Date is before nextDay: true"
  print('Date is before nextDay: ${date.isBefore(nextDay)}');
  // print "Date is after nextDay: false"
  print('Date is after nextDay: ${date.isAfter(nextDay)}');


  date = Date(2020, 05, 12);

  // print "toString(): 2020-05-12"
  print('toString(): $date');
  // print "Month (May): 5"
  print('Month (May): ${date.month}');

  /// before using toYMdString() we have to initialize intl
  try {
    print('Date in YMD format: ${date.toYMdString('en_us')}');
  } catch (e) {
    print(e);
  }

  // this must be done just once for the whole application for each locale used
  await initializeDateFormatting('en_us');
  // print "Date in YMd format: 5/12/2020"
  print('Date in YMD format: ${date.toYMdString('en_us')}');

  /// intl initialization (as above) must have been performed before
  /// calling toYMMMMdString()
  // print "Date in YMMMMd format: May 12, 2020"
  print('Date in YMMMMd format: ${date.toYMMMMdString('en_us')}');

}

Use this package as a library

1. Depend on it

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


dependencies:
  vy_date: ^0.3.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:vy_date/vy_date.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Aug 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/src/date.dart.

Run dartfmt to format lib/src/date.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
intl ^0.15.7 0.15.8
quiver ^2.0.1 2.0.5
Transitive dependencies
matcher 0.12.5
meta 1.1.7
path 1.6.4
stack_trace 1.9.3
Dev dependencies
test ^1.5.2