wanasit / chrono

A natural language date parser in Javascript
MIT License
4.55k stars 340 forks source link

Incorrect Year in Date Parsing #559

Closed cdwmhcc closed 1 month ago

cdwmhcc commented 2 months ago

Description

When parsing the date string Thu Oct 26 11:00:09 EDT 2023, chrono-node incorrectly returns the date as 2024-10-26T15:00:09.000Z. This seems to be a specific issue with the handling of year calculations.

Steps to Reproduce

  1. Use the chrono-node library to parse the date string Thu Oct 26 11:00:09 EDT 2023.
  2. Observe the output, which incorrectly reflects the year as 2024.

Code to Reproduce

import * as chrono from 'chrono-node'
const parsedDate = chrono.parseDate('Thu Oct 26 11:00:09 EDT 2023')
console.log(parsedDate) //=> 2024-10-26T15:00:09.000Z
const parsedDate1 = chrono.parseDate('Thu Oct 26 11:00:09 2023')
console.log(parsedDate1) // => 2024-10-26T03:00:09.000Z

Additional Information

Node.js Version: [20.13.1] Chrono-node Version: [2.7.6]

wanasit commented 1 month ago

Thanks for reporting this. I added support for this in be6e995306d2bccd0ba42a8feaf1de550f5b874f.