A .NET DateTime
value can potentially have multiple ambiguous meanings.
-
DateTime
has no inherent timezone information associated with it, aside from the timezone determined (or not determined) by theDateTime.Kind
property:- UTC (
DateTimeKind.Utc
) - local to the system (
DateTimeKind.Local
) - up for grabs (
DateTimeKind.Unspecified
)
The same
DateTime
could refer to different instants in time depending on the timezone. - UTC (
-
Even within a specific timezone, time cannot be expressed as a linear sequence of
DateTime
s -- there may be gaps (when the clock moves forward), or there may be places where the sequence doubles back (when the clock moves back). The combination of aDateTime
and a time zone may refer to 1, 0 or 2 instants in time.
This project provides a custom debugging visualizer that maps out these possible instants for a given DateTime
, using the NodaTime library. In addition, you can choose a list of timezones to apply to each of those possible instants.
-
As UTC: If the date/time is interpreted as UTC, it will refer to this instant. Because date/times in UTC are always in linear succession, this instant is unambiguous.
-
Local zone: The local timezone for the debuggee process.
-
As local -- earlier / later mapping: If the datetime is interpreted as local (to the system), it may refer to 1 instant (earlier mapping), 2 instants (earlier or later mapping), or 0 instants.
-
Additional zones: You can choose additional zones from the built-in NodaTime Tzdb and Bcl zone providers:
Choose DateTime Visualizer from the magnifying glass dropdown on an expression which references a DateTime
while in a Visual Studio debugging session. If there is only one entry, or you've previously chosen it, you can click directly on the magnifying glass.
The UI components (views and viewmodels) are also available as a NuGet package for use in your own applications.
The visualizer provides two versions: one for VS 2019, and one for VS 2017. Theoretically, the 2017 version should also work with earlier versions of VS.
The visualizer can be used with a project targeting .NET Framework 4.5+, or .NET Standard 2.0 (which includes .NET Core 2.0+).
From the project's Releases page, download the ZIP file corresponding to your Visual Studio version (2019 or 2017). Then:
- Unblock the ZIP file
- Extract the files to the visualizers folder, preserving the required folder structure.
To delete the visualizer:
- Navigate to the visualizer location. This can be done by clicking on the About link, and then clicking on the DateTimeVisualizer.dll link.
- Delete all files and folders whose name starts with
DateTimeVisualizer
. You can find these by typingname:DateTimeVisualizer
in the Windows search box.
The project makes use of submodules from Periscope and Periscope.Debuggee, so you need to clone or pull changes into the repo using --recurse-submodules
, as described in the Git documentation.
- Provide feedback to Microsoft about these limitations/issues with the visualizer API
- Test the visualizer.
- Suggest ideas and enhancements (via issues)
- Notify about bugs (via issues)
- Star the project
- Spread the word
- The NodaTime project
- John M. Wright's series on writing debugger visualizers
- Greenshot for the screenshots