Skip to content

Commit

Permalink
0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
g1eny0ung committed Feb 3, 2022
1 parent 9226606 commit 9b29c4f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/dayjs/day.dart/pull/41>
- feat: add method `subtractRound` to prevent date overflow by @g1eny0ung in <https://github.com/dayjs/day.dart/pull/42>

### Changed

- chore!: now `.add()` and `.subtract()` return nullable

### Removed

- chore!: remove useless `.isValid()`

## [0.7.2] - 2022-01-17

- Refactor internal `Unit`
Expand Down
20 changes: 14 additions & 6 deletions lib/src/day.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class Day {
return null;
}

/// Add [val] by [unit]. Supports shorthand.
/// Adds [val] by [unit]. Supports shorthand.
///
/// Example:
///
Expand All @@ -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:
///
Expand All @@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 9b29c4f

Please sign in to comment.