globalizejs / globalizejs/globalize

Date Format: fix gregorian BC era (vs. negative date years)

Open
#684 0 comments 0 reactions 0 assignees View on GitHub
bug date module
Dominant language
JavaScript
Stars
4.8k
Forks
585
PR merge metrics
No merged PRs in 30d

Description

The following negative year is incorrectly formatted using negative values. Eras aren't being handled correctly.

```js
Globalize('en').formatDate(new Date(-1,1,1), {skeleton: 'yMd'})
// > '2/1/-1'
```

Parsing is working fine.

```js
Globalize('en').parseDate('5 BC', {skeleton: 'Gy'})
// > -000004-01-01T02:00:00.000Z
Globalize('en').parseDate('1 BC', {skeleton: 'Gy'})
// > 0000-01-01T02:00:00.000Z
Globalize('en').parseDate('1 BC', {skeleton: 'Gy'})
// > 0000-01-01T02:00:00.000Z
Globalize('en').parseDate('1 AD', {skeleton: 'Gy'})
// > 0001-01-01T02:00:00.000Z
```

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.