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

as_millis function on std::time::Duration #1547

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions text/0000-as-millis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- Feature Name: as_millis
- Start Date: 2016-03-17
- RFC PR: (leave this empty)
- Rust Issue: (leave this empty)

# Summary
[summary]: #summary

Add `as_millis` function to `std::time::Duration`.

# Motivation
[motivation]: #motivation

Working with milliseconds is very common and since `std::time::Duration` has the `from_millis` and `as_secs` functions it
makes sense to create a `as_millis`.

# Detailed design
[design]: #detailed-design

Add a `as_millis` function on `std::time::Duration` that divides `self.nanos` by `NANOS_PER_MILLI` and returns it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually how this should behave? Will users typically only want the subsecond portion of the duration in milliseconds or the entire duration in milliseconds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well there could be uses for both I guess but mostly the entire duration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the usecase for the whole duration would be the main one. Another RFC should add a way to construct a subsec duration from the duration.


# Drawbacks
[drawbacks]: #drawbacks

No drawbacks.

# Alternatives
[alternatives]: #alternatives

The impact is that everytime someone wants to work with durations in milliseconds they have to convert it.

# Unresolved questions
[unresolved]: #unresolved-questions

None.