Microsoft.Bcl.TimeProvider 9.0.0-preview.3.24172.9

About

Microsoft.Bcl.TimeProvider provides time abstraction support for apps targeting .NET 7 and earlier, as well as those intended for the .NET Framework. For apps targeting .NET 8 and newer versions, referencing this package is unnecessary, as the types it contains are already included in the .NET 8 and higher platform versions.

Key Features

  • Provides a common abstraction for time-related operations.

How to Use

using System;

// A class that uses TimeProvider to get the current time in Utc coordinates
public class UtcClock
{
    private readonly TimeProvider _timeProvider;

    // Constructor that takes a TimeProvider as a dependency
    public Clock(TimeProvider timeProvider)
    {
        _timeProvider = timeProvider;
    }

    // A method that returns the current time as a string
    public string GetTime()
    {
        return _timeProvider.GetLocalNow().ToString("HH:mm:ss");
    }
}

// A class that inherits from TimeProvider and overrides the GetLocalNow method
public class UtcTimeProvider : TimeProvider
{
    // Override the GetLocalNow method to always return UTC time
    public override DateTimeOffset GetLocalNow()
    {
        return TimeProvider.System.GetUtcNow();
    }
}

Main Types

The main types provided by this library are:

  • TimeProvider
  • TimeProviderTaskExtensions

Additional Documentation

Feedback & Contributing

Microsoft.Bcl.TimeProvider is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Bcl.TimeProvider.

Packages Downloads
Polly.Core
Package Description
3
Polly.Core
Polly.Core is a .NET resilience and transient-fault-handling library that allows developers to express resilience strategies such as Retry, Circuit Breaker, Hedging, Timeout, Chaos and Fallback in a fluent and thread-safe manner.
2
Polly.Core
Polly.Core is a .NET resilience and transient-fault-handling library that allows developers to express resilience strategies such as Retry, Circuit Breaker, Hedging, Timeout, Chaos and Fallback in a fluent and thread-safe manner.
3
Polly.Core
Polly.Core is a .NET resilience and transient-fault-handling library that allows developers to express resilience strategies such as Retry, Circuit Breaker, Hedging, Timeout, Chaos and Fallback in a fluent and thread-safe manner.
6
Yarp.ReverseProxy
Reverse proxy toolkit for building fast proxy servers in .NET using the infrastructure from ASP.NET and .NET
6
Yarp.ReverseProxy
Reverse proxy toolkit for building fast proxy servers in .NET using the infrastructure from ASP.NET and .NET
8

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
9.0.0-preview.3.24172.9 3 04/16/2024
9.0.0-preview.2.24128.5 3 03/13/2024
9.0.0-preview.1.24080.9 2 03/14/2024
8.0.1 3 03/14/2024
8.0.0 8 11/16/2023
8.0.0-rc.2.23479.6 3 11/11/2023
8.0.0-rc.1.23419.4 3 11/10/2023
8.0.0-preview.7.23375.6 2 11/11/2023
8.0.0-preview.6.23329.7 4 11/10/2023
8.0.0-preview.5.23280.8 2 11/11/2023
8.0.0-preview.4.23259.5 3 11/10/2023