iamkun / iamkun/dayjs

Date before 0001-01-01 is not properly parsed

Open
#2,298 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

When calling val1.toISOString(), returned value is `0001-01-01T00:15:28.000Z`

```
var assert = require('assert');
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');

dayjs.extend(utc); dayjs.extend(timezone);

dayjs.tz.setDefault("America/Toronto");
minDate = "0001-01-01T00:00:00.000Z";
val1 = dayjs.tz(dayjs(minDate));

assert(minDate === val1.toISOString());
// value is "0001-01-01T00:15:28.000Z"
// instead of "0001-01-01T00:00:00.000Z"
```

**Expected behavior**
Returned value should be `0001-01-01T00:00:00.000Z`

**Information**
- Day.js Version 1.11.7
- OS: Windows 10
- Browser N/A Node v18.15.0
- Time zone: [e.g. GMT-04:00 EDT (Eastern Daylight Saving Time)]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.