iamkun / iamkun/dayjs

extend How to only affect the current

Open
#1,243 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

How does the set extension only affect the current, not the overall situation
```
const config = {
thresholds: [
{ l: 's', r: 44, d: S },
{ l: 'm', r: 89 },
{ l: 'mm', r: 44, d: MIN },
{ l: 'h', r: 89 },
{ l: 'hh', r: 21 * 60, d: MIN },
{ l: 'd', r: 1 },
{ l: 'dd', r: Infinity, d: H },
],
};
dayjs.extend(relativeTime, config)
dayjs.extend(updateLocale);
dayjs.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: (number: number) => {
return getHourRelative(number, true)
},
d: 'a day',
dd: (number: number) => {
return getDayRelative(number, true)
},
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
}
})
```

Contributor guide

Open the contributing guide

Research direction

Clarify whether the relativeTime configuration passed to dayjs.extend should affect only the current use or the overall library, and define the intended scope of updateLocale('en'). Reproduce the provided example and compare relative-time output before and after the extension; completion requires an agreed behavior and tests for that scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.