UNPKG

4.5 kBMarkdownView Raw
1[![All dependencies](https://img.shields.io/librariesio/release/npm/verbal-time/2.1.0?style=flat-square "All dependencies of verbal-time@2.1.0")](https://libraries.io/npm/verbal-time/2.1.0)
2[![Reported vulnerabilities](https://img.shields.io/snyk/vulnerabilities/npm/verbal-time@2.1.0?style=flat-square "Reported vulnerabilities of verbal-time@2.1.0")](https://snyk.io/test/npm/verbal-time/2.1.0)
3[![Commits](https://flat.badgen.net/github/commits/ArthurKa/verbal-time)](https://github.com/ArthurKa/verbal-time/commits/master)
4[![NPM-version](https://img.shields.io/badge/npm-v2.1.0-blue.svg?style=flat-square&&logo=npm "Current NPM-version")](https://www.npmjs.com/package/verbal-time/v/2.1.0)
5[![Total downloads](https://img.shields.io/npm/dt/verbal-time?style=flat-square "Total downloads for all the time")](https://npm-stat.com/charts.html?package=verbal-time)
6[![Developed by](https://img.shields.io/badge/developed_by-ArthurKa-blueviolet.svg?style=flat-square "Have any questions? You are always welcome.")](https://github.com/ArthurKa/verbal-time/issues)\
7[![Publish size](https://flat.badgen.net/packagephobia/publish/verbal-time@2.1.0?label=publish 'Publish size of verbal-time@2.1.0')](https://packagephobia.now.sh/result?p=verbal-time@2.1.0)
8[![Install size](https://flat.badgen.net/packagephobia/install/verbal-time@2.1.0?label=install 'Install size of verbal-time@2.1.0')](https://packagephobia.now.sh/result?p=verbal-time@2.1.0)
9[![Minified size](https://img.shields.io/bundlephobia/min/verbal-time@2.1.0?style=flat-square&label=minified "Minified size of verbal-time@2.1.0")](https://bundlephobia.com/result?p=verbal-time@2.1.0)
10[![Minified + gzipped size](https://img.shields.io/bundlephobia/minzip/verbal-time@2.1.0?style=flat-square&label=minzipped "Minified + gzipped size of verbal-time@2.1.0")](https://bundlephobia.com/result?p=verbal-time@2.1.0)
11
12# verbal-time@2.1.0
13
14Spells time in words. Supports only **Russian** and **Ukrainian** languages.
15
16## Installation
17`verbal-time` is available via npm:
18``` bash
19$ npm i verbal-time@2.1.0
20```
21
22## Usage
23### Basic
24```ts
25import verbalTime from 'verbal-time';
26
27console.log(verbalTime(new Date('2019-09-27 12:00'))); // Полдень
28console.log(verbalTime(new Date('2019-09-27 12:20'))); // 20 минут первого
29console.log(verbalTime(new Date('2019-09-27 17:50'))); // Без 10 шесть
30console.log(verbalTime(new Date('2019-09-27 06:30'))); // Половина седьмого
31```
32
33### With configuration
34```ts
35import verbalTime from 'verbal-time';
36
37verbalTime({ lang: 'ua' });
38
39console.log(verbalTime(new Date('2019-09-27 15:00'))); // Третя дня
40console.log(verbalTime(new Date('2019-09-27 19:20'))); // 20 хвилин на восьму
41console.log(verbalTime(new Date('2019-09-27 06:30'))); // Пів на сьому
42console.log(verbalTime(new Date('2019-09-27 16:40'))); // За 20 п'ята
43
44verbalTime({ spellCountDownMinutes: true });
45console.log(verbalTime(new Date('2019-09-27 16:40'))); // За 20 хвилин п'ята
46```
47
48## Configuration properties
49`lang`: 'ru' or 'ua' (default **'ru'**) — Russian or Ukrainian text language.
50
51`countDownFrom`: 0..60 (default **30**) — the first minute that begins to be like in example.
52### Example
53```ts
54import verbalTime from 'verbal-time';
55
56verbalTime({ countDownFrom: 35 });
57
58console.log(verbalTime(new Date('2019-09-27 16:34'))); // 34 минуты пятого
59console.log(verbalTime(new Date('2019-09-27 16:35'))); // Без 25 пять
60```
61
62`spellCountDownMinutes`: Boolean (default **false**).
63### Example
64```ts
65import verbalTime from 'verbal-time';
66
67console.log(verbalTime(new Date('2019-09-27 21:53'))); // Без 7 десять
68
69verbalTime({ spellCountDownMinutes: true });
70console.log(verbalTime(new Date('2019-09-27 21:53'))); // Без 7 минут десять
71```
72
73`spellLastMinuteAsWord`: Boolean (default **true**) — to spell "1" or "минуты" last minute every hour.
74### Example
75```ts
76import verbalTime from 'verbal-time';
77
78console.log(verbalTime(new Date('2019-09-27 21:59'))); // Без минуты десять
79
80verbalTime({ spellLastMinuteAsWord: false });
81console.log(verbalTime(new Date('2019-09-27 21:59'))); // Без 1 десять
82```
83
84## Testing
85Manually tested by developer. Automated tests are not provided.
86
87## See also
88- [decline-word](https://www.npmjs.com/package/decline-word)
89
90---
91
92Your improve suggestions and bug reports [are welcome](https://github.com/ArthurKa/verbal-time/issues) any time.