{"id":21301717,"url":"https://github.com/funbox/chronos","last_synced_at":"2025-07-11T20:31:17.090Z","repository":{"id":38076391,"uuid":"285800208","full_name":"funbox/chronos","owner":"funbox","description":"One library to rule the time","archived":false,"fork":false,"pushed_at":"2023-07-18T23:29:14.000Z","size":1093,"stargazers_count":17,"open_issues_count":1,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-25T03:46:35.433Z","etag":null,"topics":["date","datetime","moment","time"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-07T10:17:23.000Z","updated_at":"2024-01-30T14:36:12.000Z","dependencies_parsed_at":"2023-02-15T09:00:48.401Z","dependency_job_id":null,"html_url":"https://github.com/funbox/chronos","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/funbox/chronos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fchronos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fchronos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fchronos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fchronos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funbox","download_url":"https://codeload.github.com/funbox/chronos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fchronos/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261877297,"owners_count":23223684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","datetime","moment","time"],"created_at":"2024-11-21T15:50:31.347Z","updated_at":"2025-07-11T20:31:12.080Z","avatar_url":"https://github.com/funbox.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/avatar.png\" width=\"80\" alt=\"Chronos avatar: white-on-black gloomy antique half-human half-clock face\" /\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@funboxteam/chronos\"\u003e\n    \u003cimg alt=\"npm\" src=\"https://img.shields.io/npm/v/@funboxteam/chronos.svg?color=000\u0026labelColor=888\" /\u003e\n  \u003c/a\u003e\n  \n  \u003ca href=\"https://github.com/funbox/chronos/actions/workflows/node.js.yml\"\u003e\n    \u003cimg alt=\"CI status\" src=\"https://img.shields.io/github/actions/workflow/status/funbox/chronos/node.js.yml?color=000\u0026labelColor=888\" /\u003e\n  \u003c/a\u003e\n  \n  \u003ca href=\"https://coveralls.io/github/funbox/chronos\"\u003e\n    \u003cimg alt=\"Code coverage\" src=\"https://img.shields.io/coveralls/github/funbox/chronos?color=000\u0026labelColor=888\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cb\u003eChronos\u003c/b\u003e is a tiny, immutable, typed date manipulation library which does not bloat your JS bundle,\u003cbr/\u003e\n  but does everything you need.\n\u003c/div\u003e\n\n## Features\n\n\u003cimg src=\"images/picture.png\" align=\"right\" width=\"250\" alt=\"Chronos picture: gloomy antique half-human half-clock carved in stone face\" /\u003e\n\n- **Immutable \u0026 pure function per file.** Every function does not have side effects, nor mutates the params.\n  If you use a function, only this function is added to your bundle, not the whole lib.\n- **ESM \u0026 CommonJS.** Works in Node.js and browser. Setup the target browsers for transpiling ES6 by your own in your bundler.  \n- **TypeScript.** Every function is typed and the typings are bundled with the package.\n- **Native API.** Uses `Date` and `Intl` under the hood.\n- **Russian locale only.** And it has docs [in Russian](./README.ru.md).\n\n## Rationale\n\nWhen we started to develop our projects, we picked the most popular date library that existed back then. \nWe had used only two methods it provided, but got all the bundled ones, with all the possible locales.\n\nOK, we set up our bundler configs to remove those locales, but still that library was the biggest that we used, but the profit wasn't so huge.\nWe decided to look around for the date library that we need, but all of them had a lot of features that we didn't want to use.\n\nSo we replaced it with small and lightweight functions that just worked. \nStep by step those functions have evolved into Chronos—simple yet useful date manipulation library that works in every our project.\n\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Types](#types)\n  - [ChronosDate](#chronosdate)\n  - [Duration](#duration)\n- [Functions](#functions)\n  - [addMinutes](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [addHours](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [addDays](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [addMonths](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [addCalendarMonths](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [addYears](#addminutes-addhours-adddays-addmonths-addcalendarmonths-addyears)\n  - [subtractMinutes](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [subtractHours](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [subtractDays](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [subtractMonths](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [subtractCalendarMonths](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [subtractYears](#subtractminutes-subtracthours-subtractdays-subtractmonths-subtractcalendarmonths-subtractyears)\n  - [formatDate](#formatdate)\n  - [formatTimeString](#formattimestring)\n  - [getMinutes](#getminutes-gethours-getday-getmonth-getyear)\n  - [getHours](#getminutes-gethours-getday-getmonth-getyear)\n  - [getDay](#getminutes-gethours-getday-getmonth-getyear)\n  - [getMonth](#getminutes-gethours-getday-getmonth-getyear)\n  - [getYear](#getminutes-gethours-getday-getmonth-getyear)\n  - [getWeekdayName](#getweekdayname-getmonthname)\n  - [getMonthName](#getweekdayname-getmonthname)\n  - [getDuration](#getduration)\n  - [isSameMinute](#issameminute-issamehour-issameday-issamemonth-issameyear)\n  - [isSameHour](#issameminute-issamehour-issameday-issamemonth-issameyear)\n  - [isSameDay](#issameminute-issamehour-issameday-issamemonth-issameyear)\n  - [isSameMonth](#issameminute-issamehour-issameday-issamemonth-issameyear)\n  - [isSameYear](#issameminute-issamehour-issameday-issamemonth-issameyear)\n  - [getDiffInMinutes](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInHours](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInDays](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInCalendarDays](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInMonths](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInCalendarMonths](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInYears](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getDiffInCalendarYears](#getdiffinminutes-getdiffinhours-getdiffindays-getdiffincalendardays-getdiffinmonths-getdiffincalendarmonths-getdiffinyears-getdiffincalendaryears)\n  - [getStartOfMinutes](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfHours](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfDay](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfWeek](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfMonth](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfYear](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getStartOfDecade](#getstartofminutes-getstartofhours-getstartofday-getstartofweek-getstartofmonth-getstartofyear-getstartofdecade)\n  - [getEndOfMinutes](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfHours](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfDay](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfWeek](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfMonth](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfYear](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getEndOfDecade](#getendofminutes-getendofhours-getendofday-getendofweek-getendofmonth-getendofyear-getendofdecade)\n  - [getRelativeDate](#getrelativedate)\n  - [getUtcOffset](#getutcoffset)\n  - [getUnixTimestamp](#getunixtimestamp)\n  - [getTimezoneName](#gettimezonename)\n  - [isTimeValid](#istimevalid)\n  - [parseDate](#parsedate)\n- [Credits](#credits)\n\n## Getting Started\n\nAdd the package into deps:\n\n```bash\nnpm install --save @funboxteam/chronos\n```\n\nImport functions:\n\n```js\nimport { addYears } from '@funboxteam/chronos';\n```\n\n\n## Types\n\nThe library exports several types that may be used elsewhere, but the most important that they used inside the lib\nto guarantee type safety.\n\n### ChronosDate\n\n```typescript\ndeclare type ChronosDate = Date | number | string;\n```\n\nEvery function that accepts date as a first param expects to get an instance of `Date`, or a timestamp as number or string.\n\nThe timestamp may be present as seconds or milliseconds (e.g. `1596803254000` and `1596803254` is the same value).\n\n### Duration\n\n```typescript\ndeclare type Duration = {\n  days: number;\n  hours: number;\n  minutes: number;\n  seconds: number;\n};\n```\n\nType describing return value of functions that work with time intervals. \n\n## Functions\n\nEvery function is immutable and those which accept `Date` instances and return `Date` instance always return \nnew `Date` instance and do not mutate the passed one.\n\n### [addMinutes](./lib/addMinutes.ts), [addHours](./lib/addHours.ts), [addDays](./lib/addDays.ts), [addMonths](./lib/addMonths.ts), [addCalendarMonths](./lib/addCalendarMonths.ts), [addYears](./lib/addYears.ts)\n\n```typescript\n(value: ChronosDate, quantity: number) =\u003e Date;\n```\n\n#### Params\n\n- `value`, date value;\n- `quantity`, number of units to add.\n\n#### Example\n\n```js\naddDays(new Date('2020-01-01T00:00:00.000Z'), 1); // 2020-01-02T00:00:00.000Z\n\n// 1577836800 is 2020-01-01T00:00:00.000Z\naddYears(1577836800, 1); // 2021-01-01T00:00:00.000Z\n\naddMonths(new Date(2020, 0, 1), 1); // == new Date(2020, 1, 1);\naddMonths(new Date(2020, 0, 31), 1); // == new Date(2020, 2, 2);\n\naddCalendarMonths(new Date(2020, 0, 1), 1); // == new Date(2020, 1, 1);\naddCalendarMonths(new Date(2020, 0, 31), 1); // == new Date(2020, 1, 29);\n```\n\n### [subtractMinutes](./lib/subtractMinutes.ts), [subtractHours](./lib/subtractHours.ts), [subtractDays](./lib/subtractDays.ts), [subtractMonths](./lib/subtractMonths.ts), [subtractCalendarMonths](./lib/subtractCalendarMonths.ts), [subtractYears](./lib/subtractYears.ts)\n\n```typescript\n(value: ChronosDate, quantity: number) =\u003e Date;\n```\n\n#### Params\n\n- `value`, date value;\n- `quantity`, number of units to subtract.\n\n#### Example\n\n```js\nsubtractDays(new Date('2020-01-01T00:00:00.000Z'), 1); // 2019-12-31T00:00:00.000Z\n\n// 1577836800 is 2020-01-01T00:00:00.000Z\nsubtractYears(1577836800, 1); // 2019-01-01T00:00:00.000Z\n\nsubtractMonths(new Date(2020, 0, 1), 1); // == new Date(2019, 11, 1);\nsubtractMonths(new Date(2020, 2, 31), 1); // == new Date(2020, 2, 2);\n\nsubtractCalendarMonths(new Date(2020, 0, 1), 1); // == new Date(2019, 11, 1);\nsubtractCalendarMonths(new Date(2020, 2, 31), 1); // == new Date(2020, 1, 29);\n```\n\n### [formatDate](./lib/formatDate.ts)\n\n```typescript\n(value: ChronosDate, format: string) =\u003e string;\n```\n\n#### Params\n\n- `value`, date value;\n- `format`, desired format.\n\n#### Available format tokens\n      \n| Type            | Token  | Value                                           |\n|:----------------|:-------|:------------------------------------------------|\n| Second          | `ss`   | 00, 01, 02, ..., 57, 58, 59                     |\n| Minute          | `mm`   | 00, 01, 02, ..., 57, 58, 59                     |\n| Hour            | `HH`   | 00, 01, 02, ..., 21, 22, 23                     |\n| Day of Week     | `dddd` | понедельник, вторник, ..., суббота, воскресенье |\n| Day of Month    | `DD`   | 01, 02, 03, ..., 29, 30, 31                     |\n|                 | `D`    | 1, 2, 3, ..., 29, 30, 31                        |\n| Month           | `MMMM` | январь, февраль, ..., ноябрь, декабрь           |\n|                 | `MMM`  | янв, фев, ..., ноя, дек                         |\n|                 | `MM`   | 01, 02, 03, ..., 10, 11, 12                     |\n| Year            | `YYYY` | Full year, e.g.: 1885, 1955, 1985, 2015         |\n|                 | `YY`   | 00, 01, 02, ..., 97, 98, 99                     |\n| UTC time offset | `ZZ`   | -1200, -1100, ..., +1300, +1400                 |\n|                 | `Z`    | -12:00, -11:00, ..., +13:00, +14:00             |\n   \n#### Example\n\n```js\nformatDate(new Date(2020, 0, 1), 'YYYY-MM-DDTHH:mm:ssZ'); // '2020-01-01T00:00:00+03:00' (for GMT+3)\n\n// 1577836800 is 2020-01-01T00:00:00.000Z\nformatDate(1577836800, 'HH:mm:ss'); // '03:00:00' (for GMT+3)\n```\n\n#### Important notes\n\nOnly Russian locale is supported for now!\n\n\n### [formatTimeString](./lib/formatTimeString.ts)\n\n```typescript\n(value: string, valueFormat: string, format: string) =\u003e string;\n```\n\n#### Params\n\n- `value`, time string;\n- `valueFormat`, template describing `value` format;\n- `format`, desired format.\n\n#### Available format tokens\n\n| Type   | Token | Value                       |\n|:-------|:------|:----------------------------|\n| Second | `ss`  | 00, 01, 02, ..., 57, 58, 59 |\n| Minute | `mm`  | 00, 01, 02, ..., 57, 58, 59 |\n| Hour   | `HH`  | 00, 01, 02, ..., 21, 22, 23 |\n|        | `H`   | 0, 1, 2, ..., 21, 22, 23    |\n\n#### Example\n\n```js\nformatTimeString('22:00', 'HH:mm', 'HH:mm:ss'); // '22:00:00'\n```\n\n\n### [getMinutes](./lib/getMinutes.ts), [getHours](./lib/getHours.ts), [getDay](./lib/getDay.ts), [getMonth](./lib/getMonth.ts), [getYear](./lib/getYear.ts)\n\n```typescript\n(value: ChronosDate) =\u003e number;\n```\n\n#### Params\n\n- `value`, date value.\n\n#### Example\n\n```js\ngetDay(new Date(2020, 0, 1)); // 1;\n\n// 1577836800 is 2020-01-01T00:00:00.000Z\ngetYear(1577836800); // 2020\n```\n\n### [getWeekdayName](./lib/getWeekdayName.ts), [getMonthName](./lib/getMonthName.ts)\n\n```typescript\n(value: ChronosDate, format?: string) =\u003e string;\n```\n\n#### Params\n\n- `value`, date value;\n- `format`, format of the returned string. `'long'` (by default) or `'short'`. \n\n#### Example\n\n```js\ngetWeekdayName(new Date(2020, 11, 30)); // 'среда' (11th month in JS is December)\ngetWeekdayName(new Date(2020, 11, 30), 'short'); // 'ср'\ngetMonthName(new Date(2020, 0, 1)); // 'январь'\ngetMonthName(new Date(2020, 0, 1), 'short'); // 'янв'\n```\n\n\n### [getDuration](./lib/getDuration.ts)\n\n```typescript\n(seconds: number) =\u003e Duration;\n```\n\n### Params\n\n- `seconds`, interval value in seconds.\n\n#### Example\n\n```js\ngetDuration(1000000); // { days: 11, hours: 13, minutes: 46, seconds: 40 }\n```\n\n\n### [isSameMinute](./lib/isSameMinute.ts), [isSameHour](./lib/isSameHour.ts), [isSameDay](./lib/isSameDay.ts), [isSameMonth](./lib/isSameMonth.ts), [isSameYear](./lib/isSameYear.ts)\n\n```typescript\n(firstValue: ChronosDate, secondValue: ChronosDate) =\u003e boolean;\n```\n\n#### Params\n\n- `firstValue`, date value;\n- `secondValue`, date value.\n\n#### Example\n\n```js\n// 1577750400 is 2019-12-31T00:00:00.000Z\n// 1577836800 is 2020-01-01T00:00:00.000Z\nisSameYear(1577750400, 1577836800); // false\n```\n\n\n### [getDiffInMinutes](./lib/getDiffInMinutes.ts), [getDiffInHours](./lib/getDiffInHours.ts), [getDiffInDays](./lib/getDiffInDays.ts), [getDiffInCalendarDays](./lib/getDiffInCalendarDays.ts), [getDiffInMonths](./lib/getDiffInMonths.ts), [getDiffInCalendarMonths](./lib/getDiffInCalendarMonths.ts), [getDiffInYears](./lib/getDiffInYears.ts), [getDiffInCalendarYears](./lib/getDiffInCalendarYears.ts)\n\n```typescript\n(firstValue: ChronosDate, secondValue: ChronosDate) =\u003e number;\n```\n\n#### Params\n\n- `firstValue`, date value;\n- `secondValue`, date value.\n\n#### Example\n\n```js\n// 1577750400 is 2019-12-31T00:00:00.000Z\n// 1577836800 is 2020-01-01T00:00:00.000Z\ngetDiffInDays(1577750400, 1577836800); // -1\n```\n\n\n### [getStartOfMinutes](./lib/getStartOfMinutes.ts), [getStartOfHours](./lib/getStartOfHours.ts), [getStartOfDay](./lib/getStartOfDay.ts), [getStartOfWeek](./lib/getStartOfWeek), [getStartOfMonth](./lib/getStartOfMonth.ts), [getStartOfYear](./lib/getStartOfYear.ts), [getStartOfDecade](./lib/getStartOfDecade.ts)\n\n```typescript\n(value: ChronosDate, diff?: number) =\u003e Date;\n```\n\n#### Params\n- `value`, date value;\n- `diff`, number of units to add to the result date. `0` by default.\n\n#### Example\n\n```js\n// 1577836800 is 2020-01-01T00:00:00.000Z\ngetStartOfDay(1577836800); // 2019-12-31T21:00:00.000Z (for GMT+3)\ngetStartOfDay(1577836800, 1); // 2020-01-01T21:00:00.000Z (for GMT+3)\ngetStartOfDay(1577836800, -1); // 2019-12-30T21:00:00.000Z (for GMT+3)\n```\n\n\n### [getEndOfMinutes](./lib/getEndOfMinutes.ts), [getEndOfHours](./lib/getEndOfHours.ts), [getEndOfDay](./lib/getEndOfDay.ts), [getEndOfWeek](./lib/getEndOfWeek.ts), [getEndOfMonth](./lib/getEndOfMonth.ts), [getEndOfYear](./lib/getEndOfYear.ts), [getEndOfDecade](./lib/getEndOfDecade.ts)\n\n```typescript\n(value: ChronosDate, diff?: number) =\u003e Date;\n```\n\n#### Params\n- `value`, date value;\n- `diff`, number of units to add to the result date. `0` by default.\n\n#### Example\n\n```js\n// 1577836800 is 2020-01-01T00:00:00.000Z\ngetEndOfDay(1577836800); // 2020-01-01T20:59:59.999Z (for GMT+3)\ngetEndOfDay(1577836800, 1); // 2020-01-02T20:59:59.999Z (for GMT+3)\ngetEndOfDay(1577836800, -1); // 2019-12-31T20:59:59.999Z (for GMT+3)\n```\n\n\n### [getRelativeDate](./lib/getRelativeDate.ts)\n\n```typescript\n(value: ChronosDate) =\u003e string;\n```\n\n#### Params\n\n- `value`, date value.\n\n#### Example\n\n```js\ngetRelativeDate(1577081613); // '2 месяца' (for 07.02.2020)\ngetRelativeDate(new Date()); // 'меньше минуты'\n```\n\n\n### [getUtcOffset](./lib/getUtcOffset.ts)\n\n```typescript\n(value: ChronosDate) =\u003e number;\n```\n\n#### Params\n\n- `value`, date value.\n\n#### Example\n\n```js\ngetUtcOffset(new Date(2020, 0, 1)); // 3 (for GMT+3)\n```\n\n\n### [getUnixTimestamp](./lib/getUnixTimestamp.ts)\n\n```typescript\n(date?: Date) =\u003e number;\n```\n\n#### Params\n\n- `date`, Date instance. `new Date()` by default.\n\n#### Example\n\n```js\n// now is 2020-02-07T08:26:59.422Z\ngetUnixTimestamp(); // 1581064019 (unix timestamp for new Date())\n\ngetUnixTimestamp(new Date(2020, 0, 1)); // 1577826000 (for GMT+3)\n```\n\n\n### [getTimezoneName](./lib/getTimezoneName.ts)\n\n```typescript\n() =\u003e string;\n```\n\n#### Example\n\n```js\ngetTimezoneName(); // 'Europe/Moscow' (for any GMT+3 timezone in IE11 and for MSK in modern browsers)\n```\n\n#### Important notes\n\nIn case of lack of Intl API support returns nearest to the user timezone \nwhich has _integer hours offset_.\n\n\n### [isTimeValid](./lib/isTimeValid.ts)\n\n```typescript\n(value: string, format: string) =\u003e boolean;\n```\n\n#### Params\n\n- `value`, time string;\n- `format`, format string that should be used for validation.\n\n#### Example\n\n```js\nisTimeValid('22:30', 'HH:mm'); // true\n```\n\n\n### [parseDate](./lib/parseDate.ts)\n\n```typescript\n(value: string, format: string) =\u003e Date;\n```\n\n#### Params\n\n- `value`, date string;\n- `format`, format string that should be used for parsing.\n\n#### Available format tokens    \n      \n| Type         | Token  | Recognized values                       |\n|:-------------|:-------|:----------------------------------------|\n| Day of Month | `DD`   | 01, 02, 03, ..., 29, 30, 31             |\n|              | `D`    | 1, 2, 3, ..., 29, 30, 31                |\n| Month        | `MM`   | 01, 02, 03, ..., 10, 11, 12             |\n| Year         | `YYYY` | Full year, e.g.: 1885, 1955, 1985, 2015 |\n|              | `YY`   | 00, 01, 02, ..., 97, 98, 99             |\n\n#### Example\n\n```js\nparseDate('2000-01-21', 'YYYY-MM-DD'); // == new Date(2000, 0, 21)\nparseDate('2020-01-01T00:00:00+03:00'); // == new Date(2020, 0, 1) (for GMT+3)\n```\n\n#### Important notes\n\nIf `format` is not passed it tries to parse `value` using native\n`Date.parse`. It should support ISO 8601 and RFC 2822. Other formats\nare not recommended to parse without explicit `format` set.\n\n\n## Credits\n\nProject's pictures were made by [Igor Garybaldi](https://pandabanda.com/).\n\n\n[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_grayscale.svg)](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fchronos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunbox%2Fchronos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fchronos/lists"}