druidengine / druidengine/druid

Implement Duration module to provide time conversion utility functions.

Open
#41 2 comments 0 reactions 1 assignee Claimed by @harshit-sharma2005 View on GitHub
enhancement good first issue
Dominant language
C++
Stars
3
Forks
6
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
Current time conversion using chrono is verbose. Also, time as a double isn't supported out of the box.

**Describe the solution you'd like**

- [ ] Define `std::chrono::duration` as `druid::core::seconds`
- [ ] Implement functions to convert a `std::chrono::stead_clock::duration`:
- [ ] `druid::core::to_seconds() -> seconds`
- [ ] `druid::core::to_milliseconds() -> std::chrono::milliseconds`
- [ ] `druid::core::to_microseconds() -> std::chrono::microseconds`
- [ ] `druid::core::to_nanoseconds() -> std::chrono::nanoseconds`
- [ ] Implement appropriate tests in `Duration.test.cpp`

**Describe alternatives you've considered**

I considered making this a class `Duration` with methods for the conversion but I think this a little nicer to maintain.

**Additional context**
This is really needed for the `seconds` type we'll get from this. Most math / physics work off of fractional seconds.

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.