{"id":335513,"date":"2022-07-09T09:00:16","date_gmt":"2022-07-09T09:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335513"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335513","title":{"rendered":"<span>\u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0434\u0430\u0442 \u0432 JS \u2014\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 Chrono<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/wanasit\/chrono\" rel=\"noopener noreferrer nofollow\">Crono<\/a> \u044d\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440 \u0434\u0430\u0442 \u043d\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041a\u0440\u043e\u043c\u0435 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 ISO 8601 \u0438\u043b\u0438 dd.MM.yyyy, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0430-\u043b\u044f \u00ab\u0432 \u0441\u0440\u0435\u0434\u0443 \u0443\u0442\u0440\u043e\u043c\u200e\u00bb, \u00ab\u0441 10 \u0434\u043e 11 \u0432\u0435\u0447\u0435\u0440\u0430\u00bb, \u00ab2 \u0447\u0430\u0441\u0430 5 \u043c\u0438\u043d\u0443\u0442 \u043d\u0430\u0437\u0430\u0434\u00bb \u0438 \u0442.\u043f. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 8 \u044f\u0437\u044b\u043a\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0442\u0435\u043f\u0435\u0440\u044c, \u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/44d\/66f\/8cc\/44d66f8cc481afbe66d91b7406d7b026.jpeg\" width=\"5997\" height=\"3998\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/44d\/66f\/8cc\/44d66f8cc481afbe66d91b7406d7b026.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Chrono \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 2016 \u0433\u043e\u0434\u0430. \u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0430, \u043d\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0444\u043e\u0440\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u043e\u0441\u043d\u043e \u043f\u0430\u0440\u0441\u0438\u043b \u0434\u0430\u0442\u044b \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c. \u041f\u0440\u043e\u0448\u043b\u043e 6 \u043b\u0435\u0442, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u043b\u0430\u0441\u044c, \u0432 2020 \u0430\u0432\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043d\u0430 TypeScript, \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c. \u0420\u0435\u0448\u0438\u043b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c. <a href=\"https:\/\/github.com\/wanasit\/chrono\/pull\/458\" rel=\"noopener noreferrer nofollow\">PR<\/a> \u0432\u043c\u0451\u0440\u0434\u0436\u0438\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u044b (parsers) \u0438 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u044b (refiners). \u0418\u0437 \u043d\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432 Chrono.<\/p>\n<p><strong>\u041f\u0430\u0440\u0441\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0418\u0445 \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u0442. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0434\u0438\u043d, \u0438\u043b\u0438 \u0441\u043c\u0435\u0436\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u2014 \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0441\u0435\u0440. \u0414\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u0438\u0445 \u0441\u0435\u0439\u0447\u0430\u0441 10. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>RUCasualDateParser<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u0442\u044b \u0432\u0438\u0434\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f|\u0432\u0447\u0435\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043f\u043e\u0441\u043b\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043f\u043e\u0437\u0430\u0432\u0447\u0435\u0440\u0430.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0430\u0440\u0441\u0435\u0440\u0430:<\/p>\n<pre><code class=\"typescript\">interface Parser {     pattern: (context: ParsingContext) => RegExp \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0430\u0442,     extract: (context: ParsingContext, match: RegExpMatchArray) =>         \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u2014<strong> <\/strong>\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0438\u0445 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043e\u0431\u043e\u0433\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 \u00ab\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432 19:00\u00bb. \u041f\u0430\u0440\u0441\u0435\u0440 \u0434\u043d\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u0438\u0437\u0432\u043b\u0451\u043a \u00ab\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443\u00bb, \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u00ab\u0432 19:00\u00bb, \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u043e\u0432 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0449\u0438\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u043e\u0432. \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 \u043e\u0431\u044b\u0447\u043d\u043e 2 \u0438\u043b\u0438 3. \u041d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">export default class RUMergeDateRangeRefiner    extends AbstractMergeDateRangeRefiner {     patternBetween(): RegExp {         return \/^\\s*(\u0438 \u0434\u043e|\u0438 \u043f\u043e|\u0434\u043e|\u043f\u043e|-)\\s*$\/i;     } }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"typescript\">interface Refiner {     refine: (context: ParsingContext, results: ParsingResult[])  => ParsingResult[] }<\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439, \u043a \u0440\u0443\u0441\u0441\u043a\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>chrono.ru<\/code>.<\/p>\n<pre><code class=\"typescript\">import * as chrono from 'chrono-node';  chrono.ru.parseDate('\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'); \/\/ 2022-09-12T08:00:00.000Z      chrono.ru.parse('\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'); \/* [{      index: 18,     text: '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f',     start: ... }] *\/<\/code><\/pre>\n<p><code>parseDate<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0430\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u0434\u0430\u0442\u0443 \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <code>Date<\/code>, <code>parse<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u0442\u044b \u043a\u0430\u043a <code>ParsedResult<\/code>.<\/p>\n<pre><code class=\"typescript\">export interface ParsedResult { \/**      * \u0414\u0430\u0442\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u043e\u0438\u0441\u043a, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0438\u0436\u0435.      *\/     readonly refDate: Date; \/**      * \u0418\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f.       * \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 '\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f' \u0431\u0443\u0434\u0435\u0442 8.      *\/     readonly index: number; \/**      * \u0422\u0435\u043a\u0441\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u043e\u0439. \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 '\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'    * \u0431\u0443\u0434\u0435\u0442 '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'.      *\/     readonly text: string; \/**      * \u041b\u0438\u0431\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0443\u044e \u0434\u0430\u0442\u0443, \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0442\u044c '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'.   * \u041b\u0438\u0431\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0431\u044b\u043b\u0430,       * \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, '10 - 22 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012'.      *\/     readonly start: ParsedComponents; \/**      * \u041a\u043e\u043d\u0435\u0446 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b, \u0430 \u043d\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u0434\u0430\u0442\u0430.      *\/     readonly end?: ParsedComponents;     \/**      * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Date \u0438\u0437 result.start.      *\/     date(): Date; }<\/code><\/pre>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>start<\/code> \u0438 <code>end<\/code> \u0438\u043c\u0435\u044e\u0442 \u0442\u0438\u043f <code>ParsedComponents<\/code>. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0442\u0443, \u043d\u043e \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 <code>isCertain<\/code>.<\/p>\n<pre><code class=\"typescript\">chrono.ru.parse('\u0443\u0442\u0440\u043e\u043c')[0].start.isCertain('day'); \/\/false \u2014 \u0442\u0443\u0442 \u0434\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f chrono.ru.parse('12 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0443\u0442\u0440\u043e\u043c')[0].start.isCertain('day'); \/\/true \u2014 \u0442\u0443\u0442 \u0447\u0451\u0442\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0434\u0435\u043d\u044c<\/code><\/pre>\n<p>\u041e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"typescript\">function parse(text: string, ref?: Date, option?: ParsingOption) : ParsedResult[] {     ... } function parseDate(text: string, ref?: Date, option?: ParsingOption)       : Date {     ... }<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>ref<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0415\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u00ab\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432 21:45\u00bb \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446, \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c\u0441\u044f \u0432\u0432\u0438\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>new Date()<\/code>.<\/p>\n<p>\u0412 <code>ParsingOption<\/code> \u0435\u0441\u0442\u044c 2 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">export interface ParsingOption {     \/**      * \u0414\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u043b\u0435 reference date.      *\/     forwardDate?: boolean;      \/**      * \u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u043e\u043d      *\/     timezones?: { [tzKeyword: string]: number }; }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"typescript\">const referenceDate = new Date(2012, 7, 25); \/\/ 25 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012, \u0441\u0443\u0431\u0431\u043e\u0442\u0430   chrono.ru.parseDate('\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443', referenceDate); \/\/ 24 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012  chrono.ru.parseDate('\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443', referenceDate, { forwardDate: true }); \/\/ 31 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012, \u043f\u044f\u0442\u043d\u0438\u0446\u0430<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u2014 <code>chrono.ru.strict<\/code>. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u0432, \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b.<\/p>\n<pre><code class=\"typescript\">chrono.ru.strict.parseDate('\u0441\u0435\u0433\u043e\u0434\u043d\u044f'); \/\/ null chrono.ru.strict.parseDate('06.07.2020'); \/\/ 6 \u0438\u044e\u043b\u044f 2022<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/h2>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0448\u043b\u044b\u043c \u0432\u0435\u0447\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>10 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 &#8212; 12 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2013<\/p>\n<\/li>\n<li>\n<p>24\u0433\u043e \u043e\u043a\u0442\u044f\u0431\u0440\u044f, 9:00<\/p>\n<\/li>\n<li>\n<p>\u0432 12<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0447\u0430\u0441\u0430 \u043d\u0430\u0437\u0430\u0434<\/p>\n<\/li>\n<li>\n<p>\u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u0433<\/p>\n<\/li>\n<li>\n<p>06.09.2012<\/p>\n<\/li>\n<li>\n<p>10:00:00 &#8212; 21:45:01<\/p>\n<\/li>\n<\/ul>\n<p>\u0438 \u0442.\u0434.<\/p>\n<h2>PRs are welcome<\/h2>\n<p>\u0417\u0430 \u043e\u0431\u0440\u0430\u0437\u0435\u0446 \u0431\u0440\u0430\u043b \u043f\u0430\u0440\u0441\u0435\u0440\u044b \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0434\u0443\u0442 \u0432\u0430\u043c, \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u043f\u0435\u0440, \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 PR, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0448\u044c\u044e. \u0415\u0441\u043b\u0438 \u0438\u0448\u044c\u044e, \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/mikemikhaylov\" rel=\"noopener noreferrer nofollow\">\u043c\u0435\u043d\u044f<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/wanasit\/chrono\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><br \/><a href=\"https:\/\/www.npmjs.com\/package\/chrono-node\" rel=\"noopener noreferrer nofollow\">npm<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/676026\/\"> https:\/\/habr.com\/ru\/post\/676026\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><a href=\"https:\/\/github.com\/wanasit\/chrono\" rel=\"noopener noreferrer nofollow\">Crono<\/a> \u044d\u0442\u043e \u043f\u0430\u0440\u0441\u0435\u0440 \u0434\u0430\u0442 \u043d\u0430 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041a\u0440\u043e\u043c\u0435 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 ISO 8601 \u0438\u043b\u0438 dd.MM.yyyy, \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0430-\u043b\u044f \u00ab\u0432 \u0441\u0440\u0435\u0434\u0443 \u0443\u0442\u0440\u043e\u043c\u200e\u00bb, \u00ab\u0441 10 \u0434\u043e 11 \u0432\u0435\u0447\u0435\u0440\u0430\u00bb, \u00ab2 \u0447\u0430\u0441\u0430 5 \u043c\u0438\u043d\u0443\u0442 \u043d\u0430\u0437\u0430\u0434\u00bb \u0438 \u0442.\u043f. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 8 \u044f\u0437\u044b\u043a\u043e\u0432, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0442\u0435\u043f\u0435\u0440\u044c, \u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0439.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Chrono \u0432 \u0441\u0432\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 2016 \u0433\u043e\u0434\u0430. \u0420\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0430, \u043d\u043e \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0444\u043e\u0440\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043d\u043e\u0441\u043d\u043e \u043f\u0430\u0440\u0441\u0438\u043b \u0434\u0430\u0442\u044b \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c. \u041f\u0440\u043e\u0448\u043b\u043e 6 \u043b\u0435\u0442, \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u043b\u0430\u0441\u044c, \u0432 2020 \u0430\u0432\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u0435\u0451 \u043d\u0430 TypeScript, \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0432 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c. \u0420\u0435\u0448\u0438\u043b \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c. <a href=\"https:\/\/github.com\/wanasit\/chrono\/pull\/458\" rel=\"noopener noreferrer nofollow\">PR<\/a> \u0432\u043c\u0451\u0440\u0434\u0436\u0438\u043b\u0438, \u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430<\/h2>\n<p>\u0414\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043f\u0430\u0440\u0441\u0435\u0440\u044b (parsers) \u0438 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u044b (refiners). \u0418\u0437 \u043d\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0432 Chrono.<\/p>\n<p><strong>\u041f\u0430\u0440\u0441\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0418\u0445 \u0437\u0430\u0434\u0430\u0447\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u0434\u0430\u0442. \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0434\u0438\u043d, \u0438\u043b\u0438 \u0441\u043c\u0435\u0436\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u044b \u2014 \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0441\u0435\u0440. \u0414\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u0438\u0445 \u0441\u0435\u0439\u0447\u0430\u0441 10. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>RUCasualDateParser<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u0442\u044b \u0432\u0438\u0434\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f|\u0432\u0447\u0435\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043f\u043e\u0441\u043b\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043f\u043e\u0437\u0430\u0432\u0447\u0435\u0440\u0430.<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0430\u0440\u0441\u0435\u0440\u0430:<\/p>\n<pre><code class=\"typescript\">interface Parser {     pattern: (context: ParsingContext) => RegExp \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0434\u0430\u0442,     extract: (context: ParsingContext, match: RegExpMatchArray) =>         \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f }<\/code><\/pre>\n<p><strong>\u0420\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u044b<\/strong><\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u2014<strong> <\/strong>\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0438\u0445 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435, \u043e\u0431\u043e\u0433\u0430\u0449\u0435\u043d\u0438\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 \u00ab\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432 19:00\u00bb. \u041f\u0430\u0440\u0441\u0435\u0440 \u0434\u043d\u0435\u0439 \u043d\u0435\u0434\u0435\u043b\u0438 \u0438\u0437\u0432\u043b\u0451\u043a \u00ab\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443\u00bb, \u043f\u0430\u0440\u0441\u0435\u0440 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u00ab\u0432 19:00\u00bb, \u0437\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u043e\u0432 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0449\u0438\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0440\u0435\u0444\u0430\u0439\u043d\u0435\u0440\u043e\u0432. \u0421\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0434\u043b\u044f \u044f\u0437\u044b\u043a\u0430 \u043e\u0431\u044b\u0447\u043d\u043e 2 \u0438\u043b\u0438 3. \u041d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a:<\/p>\n<pre><code class=\"typescript\">export default class RUMergeDateRangeRefiner    extends AbstractMergeDateRangeRefiner {     patternBetween(): RegExp {         return \/^\\s*(\u0438 \u0434\u043e|\u0438 \u043f\u043e|\u0434\u043e|\u043f\u043e|-)\\s*$\/i;     } }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"typescript\">interface Refiner {     refine: (context: ParsingContext, results: ParsingResult[])  => ParsingResult[] }<\/code><\/pre>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439, \u043a \u0440\u0443\u0441\u0441\u043a\u043e\u0439 \u043b\u043e\u043a\u0430\u043b\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>chrono.ru<\/code>.<\/p>\n<pre><code class=\"typescript\">import * as chrono from 'chrono-node';  chrono.ru.parseDate('\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'); \/\/ 2022-09-12T08:00:00.000Z      chrono.ru.parse('\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'); \/* [{      index: 18,     text: '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f',     start: ... }] *\/<\/code><\/pre>\n<p><code>parseDate<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0430\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0432\u0448\u0443\u044e\u0441\u044f \u0434\u0430\u0442\u0443 \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <code>Date<\/code>, <code>parse<\/code> \u0432\u0435\u0440\u043d\u0451\u0442 \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u0442\u044b \u043a\u0430\u043a <code>ParsedResult<\/code>.<\/p>\n<pre><code class=\"typescript\">export interface ParsedResult { \/**      * \u0414\u0430\u0442\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u043f\u043e\u0438\u0441\u043a, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043d\u0438\u0436\u0435.      *\/     readonly refDate: Date; \/**      * \u0418\u043d\u0434\u0435\u043a\u0441 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f.       * \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 '\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f' \u0431\u0443\u0434\u0435\u0442 8.      *\/     readonly index: number; \/**      * \u0422\u0435\u043a\u0441\u0442 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0442\u043e\u0439. \u0414\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438 '\u0412\u0441\u0442\u0440\u0435\u0447\u0430 12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'    * \u0431\u0443\u0434\u0435\u0442 '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'.      *\/     readonly text: string; \/**      * \u041b\u0438\u0431\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u0443\u044e \u0434\u0430\u0442\u0443, \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0442\u044c '12 \u0441\u0435\u043d\u0442\u044f\u043d\u0442\u044f\u0431\u0440\u044f'.   * \u041b\u0438\u0431\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430, \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0431\u044b\u043b\u0430,       * \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, '10 - 22 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012'.      *\/     readonly start: ParsedComponents; \/**      * \u041a\u043e\u043d\u0435\u0446 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b, \u0430 \u043d\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u0430\u044f \u0434\u0430\u0442\u0430.      *\/     readonly end?: ParsedComponents;     \/**      * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Date \u0438\u0437 result.start.      *\/     date(): Date; }<\/code><\/pre>\n<p>\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>start<\/code> \u0438 <code>end<\/code> \u0438\u043c\u0435\u044e\u0442 \u0442\u0438\u043f <code>ParsedComponents<\/code>. \u0421\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0442\u0443, \u043d\u043e \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0442\u043e\u0434 <code>isCertain<\/code>.<\/p>\n<pre><code class=\"typescript\">chrono.ru.parse('\u0443\u0442\u0440\u043e\u043c')[0].start.isCertain('day'); \/\/false \u2014 \u0442\u0443\u0442 \u0434\u0435\u043d\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f chrono.ru.parse('12 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f \u0443\u0442\u0440\u043e\u043c')[0].start.isCertain('day'); \/\/true \u2014 \u0442\u0443\u0442 \u0447\u0451\u0442\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a\u043e\u0439 \u0434\u0435\u043d\u044c<\/code><\/pre>\n<p>\u041e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"typescript\">function parse(text: string, ref?: Date, option?: ParsingOption) : ParsedResult[] {     ... } function parseDate(text: string, ref?: Date, option?: ParsingOption)       : Date {     ... }<\/code><\/pre>\n<p>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>ref<\/code> \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u0415\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u00ab\u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432 21:45\u00bb \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446, \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c\u0441\u044f \u0432\u0432\u0438\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>new Date()<\/code>.<\/p>\n<p>\u0412 <code>ParsingOption<\/code> \u0435\u0441\u0442\u044c 2 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<pre><code class=\"typescript\">export interface ParsingOption {     \/**      * \u0414\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u043b\u0435 reference date.      *\/     forwardDate?: boolean;      \/**      * \u041c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u043e\u043d      *\/     timezones?: { [tzKeyword: string]: number }; }<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"typescript\">const referenceDate = new Date(2012, 7, 25); \/\/ 25 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012, \u0441\u0443\u0431\u0431\u043e\u0442\u0430   chrono.ru.parseDate('\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443', referenceDate); \/\/ 24 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012  chrono.ru.parseDate('\u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443', referenceDate, { forwardDate: true }); \/\/ 31 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 2012, \u043f\u044f\u0442\u043d\u0438\u0446\u0430<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u043f\u0430\u0440\u0441\u0435\u0440\u0430 \u2014 <code>chrono.ru.strict<\/code>. \u0421\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u0430\u0440\u0441\u0435\u0440\u043e\u0432, \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0445 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b.<\/p>\n<pre><code class=\"typescript\">chrono.ru.strict.parseDate('\u0441\u0435\u0433\u043e\u0434\u043d\u044f'); \/\/ null chrono.ru.strict.parseDate('06.07.2020'); \/\/ 6 \u0438\u044e\u043b\u044f 2022<\/code><\/pre>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432<\/h2>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0448\u043b\u044b\u043c \u0432\u0435\u0447\u0435\u0440\u043e\u043c<\/p>\n<\/li>\n<li>\n<p>10 \u0430\u0432\u0433\u0443\u0441\u0442\u0430 &#8212; 12 \u0441\u0435\u043d\u0442\u044f\u0431\u0440\u044f 2013<\/p>\n<\/li>\n<li>\n<p>24\u0433\u043e \u043e\u043a\u0442\u044f\u0431\u0440\u044f, 9:00<\/p>\n<\/li>\n<li>\n<p>\u0432 12<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0447\u0430\u0441\u0430 \u043d\u0430\u0437\u0430\u0434<\/p>\n<\/li>\n<li>\n<p>\u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0441\u044f\u0446<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0447\u0435\u0442\u0432\u0435\u0440\u0433<\/p>\n<\/li>\n<li>\n<p>06.09.2012<\/p>\n<\/li>\n<li>\n<p>10:00:00 &#8212; 21:45:01<\/p>\n<\/li>\n<\/ul>\n<p>\u0438 \u0442.\u0434.<\/p>\n<h2>PRs are welcome<\/h2>\n<p>\u0417\u0430 \u043e\u0431\u0440\u0430\u0437\u0435\u0446 \u0431\u0440\u0430\u043b \u043f\u0430\u0440\u0441\u0435\u0440\u044b \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0434\u0443\u0442 \u0432\u0430\u043c, \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u043f\u0435\u0440, \u0435\u0441\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u0442\u0435 PR, \u0438\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0438\u0448\u044c\u044e. \u0415\u0441\u043b\u0438 \u0438\u0448\u044c\u044e, \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c <a href=\"https:\/\/github.com\/mikemikhaylov\" rel=\"noopener noreferrer nofollow\">\u043c\u0435\u043d\u044f<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/wanasit\/chrono\" rel=\"noopener noreferrer nofollow\">GitHub<\/a><br \/><a href=\"https:\/\/www.npmjs.com\/package\/chrono-node\" rel=\"noopener noreferrer nofollow\">npm<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/676026\/\"> https:\/\/habr.com\/ru\/post\/676026\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-335513","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335513"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335513\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}