# bart96-format

> A node.js package for managing the date format.

Latest version **1.0.1-beta** (published 2020-01-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install bart96-format
pnpm add bart96-format
yarn add bart96-format
bun add bart96-format
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1-beta |
| Published | 2020-01-02 |
| First published | 2018-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 10.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Prjakhin Igor |
| Maintainers | bart96 |
| Keywords | date, time, format |

## Links

- npm: https://www.npmjs.com/package/bart96-format
- Repository: https://github.com/bart96-b/node-format
- Homepage: https://github.com/bart96-b/node-format#readme
- Issues: https://github.com/bart96-b/node-format/issues
- npm.io page: https://npm.io/package/bart96-format

## 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

- 1.0.1-beta (latest) — 2020-01-02
- 0.0.2-alpha — 2018-07-29
- 0.0.1-alpha — 2018-06-17
- 0.0.0-alpha — 2018-06-16

## README

# Node.js – Date format
A node.js package for managing the date format.

[![Build Status](https://travis-ci.org/bart96-b/node-format.svg)](https://travis-ci.org/bart96-b/node-format)

## Installation
```bash
$ npm install bart96-format
```

## Usage
```js
const Format = require('bart96-format');

let format = new Format();
format.datetime(); // "2018.06.14 20:08"
format.datetime(1e12); // "2001.09.09 01:46"
format.datetime(1e12, 'Year: yyyy. Day: dd') // "Year: 2001. Day: 09"

let format = new Format({datetimeTpl:'[HH:MM]'});
format.datetime(); // "20:08"
format.datetime(1e12); // "[01:46]"
format.datetime(1e12, 'Year: yyyy. Hours: HH'); // "Year: 2001. Hours: 01"

let format = new Format({durationTpl:'HH hours and MM minutes'});
format.duration(); // "0 hours and 0 minutes"
format.duration(1e7); // "2 hours and 46 minutes"
format.duration(1e7, 'Year: yy, hours: HH'); // "Year: 0. hours: 2"
format.duration(1e7, '{Year: yy,} hours: HH, days: dd'); // "hours: 2, days: 0"
format.duration(1e7, '{Year: yy,} hours: HH, {days: dd}'); // "hours: 2, "

let format = new Format({durationTpl:'HH hours and MM minutes', datetimeTpl:'[HH:MM]'});
format.datetime(1e12); // "[01:46]"
format.duration(1e7); // "2 hours and 46 minutes"
```

### Options (Object)
Parameter | Type | Optional | Default | Description
--------- | ---- | :------: | :-----: | -----------
`UTC` | boolean | ✓ | false | Using UTC
`datetimeTpl` | string | ✓ | `yyyy.mm.dd HH:MM` | Date format ([Mask options](#MaskOptions))
`durationTpl` | string | ✓ | `{ddд} {HHч} MMм` | Date format ([Mask options](#MaskOptions))

### Mask options <a name="MaskOptions"></a>
Mask | Description (leading zero for one-digit numbers)
---- | -----------
`yyyy` | Year represented by four digits.
`mm` | Month as digits.
`dd` | Day of the month as digits.
`HH` | Hours (24-hour clock).
`MM` | Minutes.
`SS` | Seconds.

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