# quartzite

> Lightweight relative date/time formatter without external dependencies.

Latest version **2.0.1** (published 2020-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install quartzite
pnpm add quartzite
yarn add quartzite
bun add quartzite
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-05-30 |
| First published | 2018-12-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Robert Dimitrov |
| Maintainers | robbdimitrov |
| Keywords | micro, relative, date, time, format, human-readable, timestamp |

## Links

- npm: https://www.npmjs.com/package/quartzite
- Repository: https://github.com/robbdimitrov/quartzite
- Homepage: https://github.com/robbdimitrov/quartzite#readme
- Issues: https://github.com/robbdimitrov/quartzite/issues
- npm.io page: https://npm.io/package/quartzite

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2020-05-30
- 2.0.0 — 2019-11-14
- 1.0.2 — 2018-12-27
- 1.0.0 — 2018-12-27

## README

# Quartzite

Lightweight relative date/time formatter without external dependencies.  
The formatter offers three styles - `short`, `medium` and `long`.

## Styles

| Short | Medium | Long |
| --- | --- | --- |
| now | Just now | Today, 18:00 |
| 25s | 25 seconds ago | Today, 18:00 |
| 30m | 30 minutes ago | Today, 17:30 |
| 18h | Today | Today 00:00 |
| 2d | Yesterday | Yesterday, 07:00 |
| 5d | November 7 | Thursday, November 7th |
| Oct 8, 2018 | October 8, 2018 | October 8th, 2018 |
| In 25s | In 25 seconds | Today, 10:00 |
| In 30m | In 30 minutes | Today, 10:30 |
| In 18h | Tomorrow | Tomorrow, 04:00 |
| In 2d | Thursday | Thursday, 10:00 |
| In 5d | November 17 | Sunday, November 17th |
| Dec 16, 2020 | December 16, 2020 | December 16th, 2020 |

## Installation

Using npm

```sh
$ npm install quartzite
```

Using cdn

```html
<script src="https://unpkg.com/quartzite/dist/quartzite.js"></script>
```

## Example

Importing as ES6 module

```javascript
import * as quartzite from 'quartzite';
```

or using CommonJS

```javascript
const quartzite = require('quartzite');
```

Create date in the past

```javascript
const date = new Date();
const yesterday = quartzite.dateByAdding('hours', date, -25);
```

Create date in the future

```javascript
const date = new Date();
const someday = quartzite.dateByAdding('days', date, 5);
```

Format date using `medium` style

```javascript
console.log(quartzite.dateString(yesterday)); // Medium is the default option
console.log(quartzite.dateString(someday, 'medium'));
```

Format date using `short` style

```javascript
console.log(quartzite.dateString(someday, 'short'));
```

Format date using `long` style

```javascript
console.log(quartzite.dateString(someday, 'long'));
```

## License

Licensed under the [MIT](LICENSE) License.

---
_Source: https://npm.io/package/quartzite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
