Skip to content

Commit c8812b6

Browse files
committed
Various tweaks
1 parent 1f53147 commit c8812b6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/standard/datetime/timeprovider-overview.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The following example demonstrates capturing elapsed time with <xref:System.Time
4444

4545
## FakeTimeProvider implementation
4646

47-
The [**Microsoft.Extensions.TimeProvider.Testing** NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.TimeProvider.Testing/) provides a controllable `TimeProvider` implementation that's suitable for unit testing.
47+
The [**Microsoft.Extensions.TimeProvider.Testing** NuGet package](https://www.nuget.org/packages/Microsoft.Extensions.TimeProvider.Testing/) provides a controllable `TimeProvider` implementation designed for unit testing.
4848

4949
The following list describes some of the capabilities of the <xref:Microsoft.Extensions.Time.Testing.FakeTimeProvider> class:
5050

@@ -54,33 +54,33 @@ The following list describes some of the capabilities of the <xref:Microsoft.Ext
5454

5555
## Custom implementation
5656

57-
While [FakeTimeProvider](#faketimeprovider-implementation) should cover most scenarios requiring control over time, you can still provide your own. Create a new class that derives from <xref:System.TimeProvider> and override members to control how time is provided. For example, the following class only provides a single date, the date of the moon landing:
57+
While [FakeTimeProvider](#faketimeprovider-implementation) should cover most scenarios requiring predictability with time, you can still provide your own implementation. Create a new class that derives from <xref:System.TimeProvider> and override members to control how time is provided. For example, the following class only provides a single date, the date of the moon landing:
5858

5959
:::code language="csharp" source="./snippets/timeprovider-overview/csharp/MoonLandingTimeProviderPST.cs" id="CustomProvider":::
6060
:::code language="vb" source="./snippets/timeprovider-overview/vb/MoonLandingTimeProviderPST.vb" id="CustomProvider":::
6161

6262
If code using this class calls `MoonLandingTimeProviderPST.GetUtcNow`, the date of the moon landing in UTC is returned. If `MoonLandingTimeProviderPST.GetLocalNow` is called, the base class applies `MoonLandingTimeProviderPST.LocalTimeZone` to `GetUtcNow` and returns the moon landing date and time in the PST timezone.
6363

64-
To demonstrate the usefulness of controlling time, consider the following example. Let's say that you're writing a calendar app that sends a greeting to the user when the app is first opened each day. The app has many hardcoded greetings for special days, such as the anniversary of the moon landing.
64+
To demonstrate the usefulness of controlling time, consider the following example. Let's say that you're writing a calendar app that sends a greeting to the user when the app is first opened each day. The app says a special greeting when the current day has an event associated with it, such as the anniversary of the moon landing.
6565

6666
:::code language="csharp" source="./snippets/timeprovider-overview/csharp/CalendarHelper.cs" id="CalendarHelper":::
6767
:::code language="vb" source="./snippets/timeprovider-overview/vb/CalendarHelper.vb" id="CalendarHelper":::
6868

69-
You might be inclined to write the previous code with <xref:System.DateTime> or <xref:System.DateTimeOffset> to get the current time, instead of <xref:System.TimeProvider>. But with unit testing, it's hard to work around <xref:System.DateTime> or <xref:System.DateTimeOffset> directly. You would need to either run the tests on the day and month of the moon landing or further abstract the code into smaller but testable units.
69+
You might be inclined to write the previous code with <xref:System.DateTime> or <xref:System.DateTimeOffset> to get the current date and time, instead of <xref:System.TimeProvider>. But with unit testing, it's hard to work around <xref:System.DateTime> or <xref:System.DateTimeOffset> directly. You would need to either run the tests on the day and month of the moon landing or further abstract the code into smaller but testable units.
7070

7171
The normal operation of your app uses `TimeProvider.System` to retrieve the current date and time:
7272

7373
:::code language="csharp" source="./snippets/timeprovider-overview/csharp/Program.cs" id="GreetingNormal":::
7474
:::code language="vb" source="./snippets/timeprovider-overview/vb/Program.vb" id="GreetingNormal":::
7575

76-
And unit tests are written to test special use cases:
76+
And unit tests can be written to test specific scenarios, such as testing the anniversary of the moon landing:
7777

7878
:::code language="csharp" source="./snippets/timeprovider-overview/csharp/Program.cs" id="GreetingMoon":::
7979
:::code language="vb" source="./snippets/timeprovider-overview/vb/Program.vb" id="GreetingMoon":::
8080

8181
## Use with .NET
8282

83-
Starting with .NET 8, the <xref:System.TimeProvider> class is provided by the runtime library. Older versions of .NET or libraries targeting .NET Standard 2.0 should use the NuGet package as described in the [Use with .NET Framework](#use-with-net-framework) section.
83+
Starting with .NET 8, the <xref:System.TimeProvider> class is provided by the runtime library. Older versions of .NET or libraries targeting .NET Standard 2.0, must reference the [**Microsoft.Bcl.TimeProvider** NuGet package](https://www.nuget.org/packages/Microsoft.Bcl.TimeProvider/).
8484

8585
## Use with .NET Framework
8686

0 commit comments

Comments
 (0)