Skip to content

🐛 Bug report: incorrect parsing when year is 3000 #636

Description

@aswath2001

Summary

When parsing a date string that contains the year 3000, chrono-node returns an incorrect result (wrong year and/or wrong date).

Steps to reproduce

Sandbox Link : https://codesandbox.io/p/sandbox/natural-time-string-parsing-with-chrono-node-1w0no

Reproducer:

import "./styles.css";
import * as chrono from "chrono-node";

const dateparse = (dateString) => {
  const parsedDate = chrono.parse(dateString);
  if (parsedDate.length > 0) {
    return parsedDate[0].start.date().toLocaleDateString();
  } else {
    return "error";
  }
};

export default function App() {
  const times = ["Jan 1 2999", "Jan 1 3000, 930"];

  return (
    <dl className="App">
      {times.map((time) => (
        <>
          <dt>{time}</dt>
          <dd>= {dateparse(time)}</dd>
          <br />
        </>
      ))}
    </dl>
  );
}

Expected behavior

I expected the parsed result to represent 3000-01-01T00:00:00 in my local timezone (or the equivalent UTC value).

Environment

chrono-node version: 2.3.4
Node.js version: v20.14.0
Platform: Windows / macOS / Linux (include version)
Locale / language: e.g. en, en_GB, etc.
Timezone: e.g. Asia/Kolkata

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions