Yesterday I had an idea for a possible experiment using Chrome's built-in AI support - looking for "date" references in strings. So for example: "I will have my new job in 12 days". Could the AI model recognize "12 days" as a date and determine what the actual date is, assuming a reference date of now? I was about to start working on a simple POC when I thought... wait... is there already a JavaScript library for this? Of course there is. The aptly named Chrono library does just that. It can parse a string with one assumed date and return the date, so for example: import * as chrono from 'chrono-node'; chrono.parseDate('An appointment on Sep 12-13'); This returns: Sat Sep 12 2026 12:00:00 GMT-0500 (Central Daylight Time). It can also take a string and give you a parsed set of results, so for example: chrono.parse('An appointment on Sep 12-13'); /* [{ index: 18, text: 'Sep 12-13', start: ... }] */ The parse method will return one result per matched item, with the result including the…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.