<commit_before>
[![daty](http://i.imgur.com/E2GKGYK.png)](#)

# daty

 [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Version](https://img.shields.io/npm/v/daty.svg)](https://www.npmjs.com/package/daty) [![Downloads](https://img.shields.io/npm/dt/daty.svg)](https://www.npmjs.com/package/daty)

> A tiny library to manage date objects.

## :cloud: Installation

```sh
$ npm i --save daty
```


## :clipboard: Example



```js
const Daty = require("daty");

// You can initialize Daty using the date parameters
var d = new Daty(2015, 11, 16);

// ...but you have friendly date formatting
console.log(d.format("LL"));
// => December 16, 2015

// Go back in the history, when the Romanian revolution started in 1989
// We will clone the current date since we will need it later.
// Also, subtract 26 years.
var revolutionDate = d.clone().subtract(26, "years");
console.log(revolutionDate.format("LLL"));
// => December 16, 1989 12:00 AM

// Make a difference in years
var difference = new Daty().diff(revolutionDate, "years");

console.log(`Right now there are ${difference} years since the Romanian revolution, 1989.`);
// => Right now there are 26 years since the Romanian revolution, 1989.
```

## :memo: Documentation


### `format(s)`
Formats the date by specifying the format.

#### Params
- **String** `s`: The date format using the [`formatoid`](https://github.com/IonicaBizau/formatoid) supported fields or the presets:
 - `L` : `M/D/YYYY`
 - `LL`: `MMMM D, YYYY`
 - `LLL`: `MMMM D, YYYY hh:mm A`
 - `LLLL`: `dddd, MMMM D, YYYY h:m A`

If not specified, the date object will be stringified using the native `toString()` method.

#### Return
- **String** The formated date.

### `add(count, what)`
Adds a specified number of units to the date.
<commit_msg>Updated docs<commit_after>
[![daty](http://i.imgur.com/E2GKGYK.png)](#)

# daty

 [![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [![Version](https://img.shields.io/npm/v/daty.svg)](https://www.npmjs.com/package/daty) [![Downloads](https://img.shields.io/npm/dt/daty.svg)](https://www.npmjs.com/package/daty)

> A tiny library to manage date objects.

## :cloud: Installation

```sh
$ npm i --save daty
```


## :clipboard: Example



```js
const Daty = require("daty");

// You can initialize Daty using the date parameters
var d = new Daty(2015, 11, 16);

// ...but you have friendly date formatting
console.log(d.format("LL"));
// => December 16, 2015

// Go back in the history, when the Romanian revolution started in 1989
// We will clone the current date since we will need it later.
// Also, subtract 26 years.
var revolutionDate = d.clone().subtract(26, "years");
console.log(revolutionDate.format("LLL"));
// => December 16, 1989 12:00 AM

// Make a difference in years
var difference = new Daty().diff(revolutionDate, "years");

console.log(`Right now there are ${difference} years since the Romanian revolution, 1989.`);
// => Right now there are 26 years since the Romanian revolution, 1989.
```

## :question: Get Help

There are few ways to get help:

 1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
 2. For bug reports and feature requests, open issues. :bug:
 3. For direct and quick help from me, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:


## :memo: Documentation


### `format(s)`
Formats the date by specifying the format.

#### Params
- **String** `s`: The date format using the [`formatoid`](https://github.com/IonicaBizau/formatoid) supported fields or the presets:
 - `L` : `M/D/YYYY`
 - `LL`: `MMMM D, YYYY`
 - `LLL`: `MMMM D, YYYY hh:mm A`
 - `LLLL`: `dddd, MMMM D, YYYY h:m A`

If not specified, the date object will be stringified using the native `toString()` method.

#### Return
- **String** The formated date.

### `add(count, what)`
Adds a specified number of units to the date.

{'fraction_non_alphanumeric': 0.1625484496124031, 'fraction_numerical': 0.021560077519379845, 'mean_word_length': 4.253180661577608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 12, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1905990', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1359, 'n_words': 460}