iamkun / iamkun/dayjs

Relative Time with timezone

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

Description

I have utc (GMT) datetime in Database and I want to convert it to specific Timezone e.g Europe/Berlin

```
let utc_time = "2021-11-23 16:00:00"; // from database
let berlin_time = dayjs(utc_time).tz("Europe/Berlin"); // convert utc_time to berlin time => 2021-11-23 17:00:00

let current_berlin_time = dayjs("2021-11-23 17:15:00"); // here simulate the current time from berlin

console.log(current_berlin_time.to(berlin_time));
```

"_current_berlin_time.to(berlin_time)_" it show "_an hour ago_" but it should show "_15 minutes ago_" or I'm wrong?

Contributor guide

Open the contributing guide

Research direction

Reproduce the supplied case using the dayjs(...).tz("Europe/Berlin") and current_berlin_time.to(berlin_time) entry points. Inspect how timezone conversion and relative-time comparison handle these values; done means the result is either corrected to 15 minutes ago or the observed behavior is clearly documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.