Skip to content

Commit

Permalink
Merge pull request #23 from jama5262/develop
Browse files Browse the repository at this point in the history
Releasing version v2.0.0
  • Loading branch information
jama5262 authored Oct 29, 2019
2 parents 08ceb90 + 9bdcf9f commit a283e86
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 243 deletions.
36 changes: 0 additions & 36 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 2.0.0

Added params to add and subtract methods
Example
```dart
Jiffy().add(days: 1);
Jiffy().add(years: 2, months: 1, duration: Duration(days: 1, hours: 30));
```

## 1.1.0

Add more functionality to parsing. These are
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[![Build Status](https://travis-ci.org/jama5262/jiffy.svg?branch=master)](https://travis-ci.org/jama5262/jiffy)
[![Coverage Status](https://coveralls.io/repos/github/jama5262/jiffy/badge.svg?branch=master)](https://coveralls.io/github/jama5262/jiffy?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub Version](https://img.shields.io/badge/pub-v1.1.0-blue)](https://pub.dev/packages/jiffy)
[![Pub Version](https://img.shields.io/badge/pub-v2.0.0-blue)](https://pub.dev/packages/jiffy)
[![Platform](https://img.shields.io/badge/platform-flutter%7Cweb%7Cdart%20vm-orange)](https://github.com/jama5262/jiffy)

Jiffy is a dart date package inspired by [momentjs](https://momentjs.com/) for parsing, manipulating, querying and formatting dates
Jiffy is a dart date time package inspired by [momentjs](https://momentjs.com/) for parsing, manipulating, querying and formatting dates

#### [Full Documentation](https://github.com/jama5262/jiffy/tree/master/doc) | [Installation](https://pub.dev/packages/jiffy#-installing-tab-) | [Examples](https://pub.dev/packages/jiffy#-example-tab-)
#### [Full Documentation](https://github.com/jama5262/jiffy/tree/v2.0.0/doc) | [Installation](https://pub.dev/packages/jiffy#-installing-tab-) | [ChangeLog](https://pub.dev/packages/jiffy#-changelog-tab-) | [Examples](https://pub.dev/packages/jiffy#-example-tab-)

# Usage

Expand Down Expand Up @@ -54,30 +54,30 @@ jiffy3.fromNow(); // 9 minutes ago

```dart
var jiffy1 = Jiffy()
..add(1, "day");
..add(duration: Duration(days: 1));
jiffy1.yMMMMd; // October 20, 2019
var jiffy2 = Jiffy()
..subtract(1, "day");
..subtract(days: 1);
jiffy2.yMMMMd; // October 18, 2019
// You can chain methods by using Dart method cascading
var jiffy3 = Jiffy()
..add(1, "day")
..add(3, "hours")
..subtract(30, "minutes");
..add(days: 1)
..add(hours: 3)
..subtract(minutes: 30);
jiffy3.yMMMMEEEEdjm; // Sunday, October 20, 2019 9:50 PM
var jiffy4 = Jiffy()
..add(1, "day")
..add(3, "hours")
..subtract(30, "minutes");
jiffy4.format("dd/MM/yyy"); // 21/10/2019
..add(duration: Duration(days: 1))
..add(duration: Duration(hours: 3))
..subtract(duration: Duration(minutes: 30));
jiffy4.format("dd/MM/yyy"); // 20/10/2019
// Months and year are added in respect to how many days there are in a months and if is a year is a leap year
Jiffy("2010-1-31", "yyyy-MM-dd"); // This is January 31
Jiffy("2010-1-31", "yyyy-MM-dd").add(1, "month"); // This is February 28
Jiffy("2010-1-31", "yyyy-MM-dd").add(months: 1); // This is February 28
```

## Locale Support
Expand Down
55 changes: 28 additions & 27 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
[![Build Status](https://travis-ci.org/jama5262/jiffy.svg?branch=master)](https://travis-ci.org/jama5262/jiffy)
[![Coverage Status](https://coveralls.io/repos/github/jama5262/jiffy/badge.svg?branch=master)](https://coveralls.io/github/jama5262/jiffy?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Pub Version](https://img.shields.io/badge/pub-v1.1.0-blue)](https://pub.dev/packages/jiffy)
[![Pub Version](https://img.shields.io/badge/pub-v2.0.0-blue)](https://pub.dev/packages/jiffy)
[![Platform](https://img.shields.io/badge/platform-flutter%7Cweb%7Cdart%20vm-orange)](https://github.com/jama5262/jiffy)

Jiffy is a dart date package inspired by [momentjs](https://momentjs.com/) for parsing, manipulating, querying and formatting dates
Jiffy is a dart date time package inspired by [momentjs](https://momentjs.com/) for parsing, manipulating, querying and formatting dates

# Table of content
- [Before Use](#before-use)
Expand Down Expand Up @@ -60,16 +60,16 @@ Jiffy is a dart date package inspired by [momentjs](https://momentjs.com/) for p
# Before Use
Almost all of Jiffy methods return a dart DateTime instance, like the `add` and `subtract` methods. Example
```dart
Jiffy().add(1, "year"); // Returns a DateTime instance
Jiffy().add(years: 1); // Returns a DateTime instance
Jiffy().utc(); // Returns a DateTime instance
```
_**But when doing a method chaining, it is recommended to use a variable.**_ The variable will then hold a Jiffy instance. Example
```dart
var jiffy = Jiffy()
..utc()
..add(1, "day")
..add(3, "hours")
..subtract(30, "minutes"); // Returns a Jiffy instance
..add(days: 1)
..add(hours: 3)
..subtract(minutes: 30); // Returns a Jiffy instance
```
Now `jiffy` variable returns a Jiffy instance. To get the date time, you can call it with the following methods
```dart
Expand All @@ -95,7 +95,7 @@ Creating a Jiffy from a string. See below
Jiffy("1995-12-25");
```

**_Note: For now, Jiffy supports only `yyyy-MM-dd` string formats. Passing string like `dd-MM-yyyy` will result in an exception. If you do need to pass, this format, `dd-MM-yyyy` or any other, should also pass a pattern of that string, Also know as `String Formatting`. See below_**
**_Note: For now, Jiffy supports only `yyyy-MM-dd` string formats. Passing string like `dd-MM-yyyy` will result in an exception. If you do need to pass this format, `dd-MM-yyyy` or any other, should also pass a pattern of that string, Also know as `String Formatting`. See below_**
```dart
Jiffy("25-12-1995", "dd-MM-yyyy");
Jiffy("12-1995", "MM-yyyy");
Expand Down Expand Up @@ -239,44 +239,37 @@ Jiffy().year;
# Manipulation

#### Add
This adds time to Jiffy by the following units years, months, weeks, days, hours, minutes, seconds and milliseconds. See below
This adds time to Jiffy by the following units years, months, weeks, days, hours, minutes, seconds and milliseconds, microseconds and duration. See below
```dart
Jiffy().add(1, "year");
Jiffy().add(3, "d");
Jiffy().add(years: 1);
Jiffy().add(days: 3);
Jiffy().add(duration: Duration(days: 3));
Jiffy().add(years: 1, weeks: 3, duration: Duration(days: 3));
```
Below are the units that can be used
Below are the params that can be used

| Key | Units |
| ------------- | ------------- |
| years | y / year / years |
| months | M / month / months |
| weeks | w / week / weeks |
| days | d / day / days |
| hours | h / hour / hours |
| minutes | m / minute /minutes |
| seconds | s / second / seconds |
| milliseconds | ms / millisecond / milliseconds |
`years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, duration`

You can also add date time with chaining using [dart method cascading](https://news.dartlang.org/2012/02/method-cascades-in-dart-posted-by-gilad.html)

```dart
var jiffy = Jiffy()
..add(7, "days")
..add(1, "month");
..add(days: 7)
..add(months: 1);
jiffy.yMMMMd; // November 27, 2019
```

**_Note: Months and year are added in respect to how many days there are in a months and if is a year is a leap year. See below_**

```dart
Jiffy("2010-1-31", "yyyy-MM-dd"); // This is January 31
Jiffy("2010-1-31", "yyyy-MM-dd").add(1, "month"); // This is February 28
Jiffy("2010-1-31", "yyyy-MM-dd").add(months: 1); // This is February 28
```
#### Subtract
This subtracts time from Jiffy by the following units years, months, weeks, days, hours, minutes, seconds and milliseconds. See below
```dart
Jiffy().subtract(1, "year");
Jiffy().subtract(3, "d");
Jiffy().subtract(years: 1);
Jiffy().subtract(days: 3);
```
#### Start of Time
This set the Jiffy date time to a specific unit in time in terms of years, months, weeks, days, hours, minutes, seconds and milliseconds. See below
Expand All @@ -290,6 +283,14 @@ Jiffy().startOf('hour'); // Set to now, but with 0 mins, 0 secs, and 0 ms
Jiffy().startOf('minute'); // Set to now, but with 0 seconds and 0 milliseconds
Jiffy().startOf('second'); // Set to now, but with 0 milliseconds;
```
You can also add method cascading to date time. See below

```dart
var jiffy1 = Jiffy()
..startOf("day")
..add(days: 1);
```

#### End of Time
This set the Jiffy date time to a specific unit in time in terms of years, months, weeks, days, hours, minutes, seconds and milliseconds. See below

Expand Down Expand Up @@ -365,7 +366,7 @@ Jiffy({
}).diff([2017, 1, 29], "day"); // 1
```

Also by default `diff` with truncate the result to return a whole number. To get decimal numbers, just pass a third param as `true`. See below
Also by default `diff` will truncate the result to return a whole number. To get decimal numbers, just pass a third param as `true`. See below
```dart
var jiffy1 = Jiffy("2008-10", "yyyy-MM");
var jiffy2 = Jiffy("2007-1", "yyyy-MM");
Expand Down
10 changes: 5 additions & 5 deletions example/jiffy_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ main() async {

// MANIPULATING DATES
var jiffy4 = Jiffy()
..add(1, "day");
..add(duration: Duration(days: 1));
jiffy4.yMMMMd; // October 20, 2019

var jiffy5 = Jiffy()
..subtract(1, "day");
..subtract(days: 1);
jiffy5.yMMMMd; // October 18, 2019

// You can chain methods by using Dart method cascading
var jiffy6 = Jiffy()
..add(1, "day")
..add(3, "hours")
..subtract(30, "minutes");
..add(days: 1)
..add(hours: 3)
..subtract(minutes: 30);
jiffy6.yMMMMEEEEdjm; // Sunday, October 20, 2019 9:50 PM

// LOCALES
Expand Down
Loading

0 comments on commit a283e86

Please sign in to comment.