From 9b29c4f9a8d710430a70b0518a58e970f04c73a5 Mon Sep 17 00:00:00 2001 From: Yue Yang Date: Fri, 4 Feb 2022 00:45:30 +0800 Subject: [PATCH] 0.8.0 --- CHANGELOG.md | 15 +++++++++++++++ lib/src/day.dart | 20 ++++++++++++++------ pubspec.yaml | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9820c7a..eaa66d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.0] - 2022-02-04 + +### Added + +- feat: add method `addRound` to prevent date overflow by @g1eny0ung in +- feat: add method `subtractRound` to prevent date overflow by @g1eny0ung in + +### Changed + +- chore!: now `.add()` and `.subtract()` return nullable + +### Removed + +- chore!: remove useless `.isValid()` + ## [0.7.2] - 2022-01-17 - Refactor internal `Unit` diff --git a/lib/src/day.dart b/lib/src/day.dart index 6dc803d..55fa0dc 100644 --- a/lib/src/day.dart +++ b/lib/src/day.dart @@ -395,7 +395,7 @@ class Day { return null; } - /// Add [val] by [unit]. Supports shorthand. + /// Adds [val] by [unit]. Supports shorthand. /// /// Example: /// @@ -405,18 +405,18 @@ class Day { /// ``` Day? add(int val, String unit) => _add(val: val, unit: unit); - /// Add [val] by [unit] but rounded. Supports shorthand. + /// Adds [val] by [unit] but rounded. Supports shorthand. /// /// Example: /// /// ```dart /// addRound(1, 'month'); - /// add(1, 'M'); + /// addRound(1, 'M'); /// ``` Day? addRound(int val, String unit) => _add(val: val, unit: unit, rounded: true); - /// Subtract [val] by [unit]. Supports shorthand. + /// Subtracts [val] by [unit]. Supports shorthand. /// /// Example: /// @@ -427,14 +427,22 @@ class Day { Day? subtract(int val, String unit) => _add(val: val, unit: unit, opposite: true); + /// Subtracts [val] by [unit] but rounded. Supports shorthand. + /// + /// Example: + /// + /// ```dart + /// subtractRound(1, 'month'); + /// subtractRound(1, 'M'); + /// ``` Day? subtractRound(int val, String unit) => _add(val: val, unit: unit, opposite: true, rounded: true); /// Alias of [add]. - dynamic inc(int val, String unit) => add(val, unit); + Day? inc(int val, String unit) => add(val, unit); /// Alias of [subtract]. - dynamic dec(int val, String unit) => subtract(val, unit); + Day? dec(int val, String unit) => subtract(val, unit); /// Format the [Day]'s displaying. /// diff --git a/pubspec.yaml b/pubspec.yaml index 230b621..f6f187a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: day -version: 0.7.2 +version: 0.8.0 description: >- A date library Day.js in dart. Day.dart is inspired by Day.js.