druidengine/druid
在 GitHub 查看Implement Duration module to provide time conversion utility functions.
Open
#41 创建于 2025年10月15日
enhancementgood first issue
仓库指标
- Star
- (3 star)
- PR 合并指标
- (PR 指标待抓取)
描述
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<double>asdruid::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.