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

[API Proposal]: Add GetElapsedTime(long) #84945

Closed
tarekgh opened this issue Apr 17, 2023 · 2 comments · Fixed by #85078
Closed

[API Proposal]: Add GetElapsedTime(long) #84945

tarekgh opened this issue Apr 17, 2023 · 2 comments · Fixed by #85078
Labels
api-approved API was approved in API review, it can be implemented area-System.DateTime partner-impact This issue impacts a partner who needs to be kept updated
Milestone

Comments

@tarekgh
Copy link
Member

tarekgh commented Apr 17, 2023

Background and motivation

We've added a useful feature called TimeProvider.GetElapsedTime(long startingTimestamp, long endingTimestamp). However, we've identified another frequently used scenario where users want to calculate the elapsed time from the starting timestamp to the current timestamp. To achieve this, users must currently call:

timeProvider.GetElapsedTime(startingTimestamp, timeProvider.GetTimestamp());

To simplify this process, we propose introducing an overload for GetElapsedTime that allows users to simply call timeProvider.GetElapsedTime(startingTimestamp) without having to manually call GetTimestamp() each time they want to calculate the elapsed time.

Also, will be consistent with Stopwatch.GetElapsedTime(system-int64)

API Proposal

namespace System
{
    public abstract class TimeProvider
    {
	    /// <summary>
	    /// Gets the elapsed time since the <paramref name="startingTimestamp"/> value retrieved using <see cref="GetTimestamp"/>.
	    /// </summary>
        public TimeSpan GetElapsedTime(long startingTimestamp)
    }
}

API Usage

long startingTimestamp = timeProvider.GetTimeStamp();

// .... do some work here

TimeSpan timeProvider.GetElapsedTime(startingTimestamp);

Alternative Designs

No response

Risks

No response

@tarekgh tarekgh added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Apr 17, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 17, 2023
@tarekgh tarekgh added area-System.DateTime and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 17, 2023
@tarekgh tarekgh added this to the 8.0.0 milestone Apr 17, 2023
@tarekgh tarekgh added the partner-impact This issue impacts a partner who needs to be kept updated label Apr 17, 2023
@tarekgh
Copy link
Member Author

tarekgh commented Apr 17, 2023

CC @sebastienros @stephentoub

@tarekgh tarekgh added api-ready-for-review API is ready for review, it is NOT ready for implementation blocked Issue/PR is blocked on something - see comments and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Apr 17, 2023
@stephentoub stephentoub added blocking Marks issues that we want to fast track in order to unblock other important work and removed blocked Issue/PR is blocked on something - see comments labels Apr 17, 2023
@bartonjs
Copy link
Member

bartonjs commented Apr 18, 2023

Video

Looks good as proposed

namespace System
{
    public partial class TimeProvider
    {
	    /// <summary>
	    /// Gets the elapsed time since the <paramref name="startingTimestamp"/> value retrieved using <see cref="GetTimestamp"/>.
	    /// </summary>
        public TimeSpan GetElapsedTime(long startingTimestamp)
    }
}

@bartonjs bartonjs added api-approved API was approved in API review, it can be implemented and removed blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Apr 18, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 19, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.DateTime partner-impact This issue impacts a partner who needs to be kept updated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants