Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

still maintained? #123

Closed
cl1ck opened this issue Sep 18, 2020 · 4 comments
Closed

still maintained? #123

cl1ck opened this issue Sep 18, 2020 · 4 comments

Comments

@cl1ck
Copy link

cl1ck commented Sep 18, 2020

Is this library still maintained? There is at least one critical pull request to correctly handle duration formatting pending for over a year, without comment.

@headzoo
Copy link
Owner

headzoo commented Sep 19, 2020

Yes, it's still maintained. I see the PR that's 6 months old but I'm not sure what problem it solves and what makes it critical, and why we would need to pull in another library for the formatting.

@cl1ck
Copy link
Author

cl1ck commented Sep 21, 2020

Hi, thanks for the reply. Both open PRs #97 and #114 basically solve the same problem: it's not possible to use the format prop with duration or durationFromNow.

Here are two examples:

<Moment
  date="2020-09-21T06:27:39-0500"
  duration="2020-09-21T04:12:15-0500"
  format="hh:mm:ss"
/>
// Outputs: 01:27:39
// Correct: 02:15:24

<Moment
  date={new Date(Date.now() - (1000 * 60 * 60 * 2 /* 2h */) - (1000 * 60 * 15 /* 15m */) - (1000 * 24 /* 24s */))}
  durationFromNow
  format="hh:mm:ss"
/>
// Outputs: 01:21:07
// Correct: 02:15:24

There is not need to pull in new library to fix it as you are already using moment-duration-format to format durations.
Just change line 213 in index.jsx to

if (format && !fromNowPeriod && !duration && !durationFromNow) {

which actually is what PR #97 and PR #114 both want to change.

PR #114 additional provides access to the trim function of moment-duration-format, which could be useful for displaying things
like a 24 hour clock, because without trim being disabled '00:06:24' would automatically be trimmed to '06:24'.

My vote would go to PR #114 if you should decide to pull one.

@headzoo
Copy link
Owner

headzoo commented Sep 28, 2020

Alright, I merged #114 and published to npm as v1.0.0.

@cl1ck
Copy link
Author

cl1ck commented Sep 29, 2020

Perfect, thanks a lot!

@cl1ck cl1ck closed this as completed Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants