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

Possible to have durations displayed in selected unit? #140

Open
Moonbase59 opened this issue Apr 24, 2021 · 5 comments
Open

Possible to have durations displayed in selected unit? #140

Moonbase59 opened this issue Apr 24, 2021 · 5 comments

Comments

@Moonbase59
Copy link

@Moonbase59 Moonbase59 commented Apr 24, 2021

Sometimes one wishes to add up durations, or simply display them in a specified unit, like minutes or hours.

Let’s take this example:

---
start: 2021-04-24T14:00
end: 2021-04-24T15:30
---

### Test duration

`= this.end - this.start`
`= (this.end - this.start).minutes`

It will display:

1 hours, 30 minutes
30

So if I specify .minutes it’ll only display the minutes part of the duration (30), not it’s actual length in minutes (90).

Any easy way to do this?

@SkepticMystic
Copy link
Contributor

@SkepticMystic SkepticMystic commented Apr 24, 2021

I wouldn't call it "easy" but this might work for now: = ((this.end - this.start).hours * 60) + (this.end - this.start).minutes

@blacksmithgu
Copy link
Owner

@blacksmithgu blacksmithgu commented Apr 25, 2021

I will add a function to do this.

@Moonbase59
Copy link
Author

@Moonbase59 Moonbase59 commented Apr 26, 2021

@SkepticMystic This wouldn’t work in all situations, just think of DST switching … and it wouldn’t just be hours, but weeks, months and years, too, you’d have to add.

Best bet might be to use moment.js internally, I think.

@SkepticMystic
Copy link
Contributor

@SkepticMystic SkepticMystic commented Apr 26, 2021

@Moonbase59 for sure, dedicated functionality for this would be way better

@TomasLinhart
Copy link

@TomasLinhart TomasLinhart commented Feb 19, 2022

I will add a function to do this.

@blacksmithgu Is it still something you want to add? I would love to have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants