{"id":16287481,"url":"https://github.com/alordash/date-parser","last_synced_at":"2025-03-20T03:30:26.268Z","repository":{"id":47604056,"uuid":"288420694","full_name":"alordash/date-parser","owner":"alordash","description":"Extracts date from natural message.","archived":false,"fork":false,"pushed_at":"2022-01-30T08:36:46.000Z","size":580,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T13:54:43.375Z","etag":null,"topics":["date","english-language","natural-language-processing","parser","parsing-library","russian-language"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@alordash/date-parser","language":"JavaScript","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/alordash.png","metadata":{"files":{"readme":"README-EN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-18T10:07:58.000Z","updated_at":"2023-10-05T13:11:42.000Z","dependencies_parsed_at":"2022-09-12T10:51:07.459Z","dependency_job_id":null,"html_url":"https://github.com/alordash/date-parser","commit_stats":null,"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alordash%2Fdate-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alordash%2Fdate-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alordash%2Fdate-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alordash%2Fdate-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alordash","download_url":"https://codeload.github.com/alordash/date-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244543687,"owners_count":20469541,"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","english-language","natural-language-processing","parser","parsing-library","russian-language"],"created_at":"2024-10-10T19:45:15.550Z","updated_at":"2025-03-20T03:30:25.862Z","avatar_url":"https://github.com/alordash.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @alordash/date-parser\n\n``` \n$ npm i @alordash/date-parser\n```  \n\n## Links\n\n* [Описание на русском языке](README.md)  \n\n# Description\n\nExtracts dates of any event from human spoken message with **seconds** precision.  \nCan return event description without date-related words.  \nIt uses my realization of **[Damerau-Levenshtein algorithm](https://github.com/alordash/damerau-levenshtein)** to properly parse words even if they are written with mistakes.  \n**Supports Russian and English languages.**  \nEasy to use, this library allows you to determine dates with absolute precision using a variety of parameters.  \n\n# Documentaion\n\n### TimeList class:\n\nEach property is *Number* that represents value of specific time type.  \nIf value is *undefined*, then source string did not contain definition of that time type.  \n\n#### Properties:  \n\n* TimeList.dates   {**Number**} —   Date.setDate(TimeList.dates);  \n* TimeList.hours   {**Number**} —   Date.setHours(TimeList.hours);  \n* TimeList.minutes {**Number**} —   Date.setMinutes(TimeList.minutes);  \n* TimeList.months  {**Number**} —   Date.setMonth(TimeList.months);  \n* TimeList.seconds {**Number**} —   Date.setSeconds(TimeList.seconds);  \n* TimeList.years   {**Number**} —   Date.setFullYear(TimeList.years);  \n\n### ParsedDate class:\n\nEvery ParsedDate object represents particular date and event retrieved from source string.\n\n#### Properties:  \n\n* ParsedDate.confidence     {**Number**}         — confidence level of this **ParsedDate**.  \n* ParsedDate.contexts       {**Array.\\\u003cNumber\\\u003e**} — technical property.  \n* ParsedDate.target_date    {**TimeList**}       — contains all information about target date of event.  \n* ParsedDate.period_time    {**TimeList**}       — contains all information about periodicity of event.  \n* ParsedDate.max_date       {**TimeList**}       — contains all information about maximum date of event.  \n* ParsedDate.string         {**String**}         — event description without date-related words.  \n* ParsedDate.isOffset       {**Boolean**}        — is this date determined with offset (using word \"*in*\").  \n* ParsedDate.isFixed        {**Boolean**}        — does contain dates with unambiguous definition (e.g. \"9 **a.m.**\").  \n\n### Function parseDate(string, errorLimit, minimumPrevalence): {Array.\\\u003cParsedDates\\\u003e}\n\n#### Arguments\n\n1. string {**String**} — source string.  \n2. errorLimit {**Number**} — From 0.0 to 1.0, the less — the less results. Used for recognizing words with mistakes.  \n3. minimumPrevalence {**Number**} — From 0 to 100, the less — the more results. Used to filter rare date cases.  \n\n# Usage\n\n```javascript\nconst { parseDate } = require('@alordash/date-parser');\n\nlet string = 'Come home at 8:30 p.m. and cook dinner. Buy milk and wash car on monday.';\nlet result = parseDate(string);\n\nconsole.log('time 1 :\u003e\u003e ', JSON.stringify(result[0].target_date));\n//=\u003e time 1 :\u003e\u003e  {\"minutes\":30,\"hours\":20}\n\nconsole.log('event 1 :\u003e\u003e ', result[0].string);\n//=\u003e event 1 :\u003e\u003e Come home and cook dinner\n\nconsole.log('time 2 :\u003e\u003e ', JSON.stringify(result[1].target_date));\n//=\u003e time 2 :\u003e\u003e  {\"dates\":31} //30.08.20 atm., 31.08.20 is Monday\n\nconsole.log('event 2 :\u003e\u003e ', result[1].string);\n//=\u003e event 2 :\u003e\u003e Buy milk and wash car\n\n//————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nstring = 'Visit doctor from 9 a.m. to 11 p.m. on next Saturday and go to shop at 7 p.m.';\nresult = parseDate(string);\n\nconsole.log('maximum date 1 :\u003e\u003e ', JSON.stringify(result[0].max_date));\n//=\u003e maximum date 1 :\u003e\u003e  {\"dates\":36,\"hours\":23} //30.08.20 atm., next saturday is on 05.09.20, which is technically 36.08.20\n\nconsole.log('target date 1 :\u003e\u003e ', JSON.stringify(result[0].target_date));\n//=\u003e target date 1 :\u003e\u003e  {\"hours\":9}\n\nconsole.log('event 1 :\u003e\u003e ', result[0].string);\n//=\u003e event 1 :\u003e\u003e Visit doctor\n\nconsole.log('target date 2 :\u003e\u003e ', JSON.stringify(result[1].target_date));\n//=\u003e target date 2 :\u003e\u003e  {\"hours\":19}\n\nconsole.log('event 2 :\u003e\u003e ', result[1].string);\n//=\u003e event 2 :\u003e\u003e go to shop\n\n//————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————\nstring = 'On 19 of September From 9:00 to 20:00 Get up from the computer every 15 minutes and do a warm-up';\nresult = parseDate(string);\n\nconsole.log('target date :\u003e\u003e ', JSON.stringify(result[0].target_date));\n//=\u003e target date :\u003e\u003e  {\"dates\":19,\"hours\":9,\"minutes\":0,\"months\":9}\n\nconsole.log('period time :\u003e\u003e ', JSON.stringify(result[0].period_time));\n//=\u003e period time :\u003e\u003e  {\"minutes\":15}\n\nconsole.log('maximum date :\u003e\u003e ', JSON.stringify(result[0].maximum_date));\n//=\u003e maximum date :\u003e\u003e  {\"hours\":20,\"minutes\":0}\n\nconsole.log('event :\u003e\u003e ', JSON.stringify(result[0].string));\n//=\u003e event :\u003e\u003e Get up from the computer and do a warm-up\n```\n\n# Features\n\n### ParsedDate.toString(): {String}\n\nReturns event description.  \n\n### ParsedDate.valueOf(): {{target_date: Date, period_time: Date, max_date: Date}}\n\nComposes all found time types to dates and returns  \n```javascript\n{\n    target_date: Date,  \n    period_time: Date,  \n    max_date: Date  \n}\n```  \nUsing current time values (**new Date()**) for not found target_dates and max_dates time types.  \nUsing null time values (**new Date(0)**) for not found period_time time types.  \n\n\n# Custom settings\n\nYou can change csv files that are used for recognition via functions ``SetExpressionsDirectoryPath(directoryPath: string)`` and ``SetSeparatorsDirectoryPath(directoryPath: string)``.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falordash%2Fdate-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falordash%2Fdate-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falordash%2Fdate-parser/lists"}