Library extending the .NET TimeSpan structure to be comparable, serializable, and convertible, and to support localized string formatting and parsing.
MIT License
Library extending the .NET TimeSpan structure to be comparable, serializable, and convertible, and to support localized string formatting and parsing.
There are three public classes of note:
TimeSpan2
is a wrapper around the existing TimeSpan
structure that adds serialization, comparability, and convertibility. It can be used anywhere a TimeSpan is used.TimeSpanFormatInfo
is an IFormatProvider
for TimeSpan instances and provides a richer set of output formats. It works similarly to DateTimeFormatInfo. If you use the TimeSpan2 structure, you can access the parsing and output functionality directly from the structure's Parse and ToString methods. A list of format strings can be found here and in the inline documentation for TimeSpanFormatInfo
.TimeSpanPicker
is a editable ComboBox that exposes a localized list of TimeSpan instances and allows for text entry. This is only available in the TimeSpan2
package.This project has translations for English, Spanish, French, Italian, Russian, Chinese, and German. If anyone would like to provide translations for other languages, or better ones for those in the project, please post them in the Discussions area.
This is a standard Visual Studio 2022 solution containing the core library and control library as projects and a test harness as another project.
It is available for inclusion into .NET projects via NuGet:
For sample code, see the Documentation.
TimeSpan2.Core
and TimeSpan2
) to remove WinForms dependency from core package.Not backwards compatible with 1.x library. Aligned and expanded upon functionality in .NET 4.0. Provides TimeSpan2FormatInfo which is culturally aware. It now provides an advanced syntax for formatting and parsing. TimeSpan2 is now functionally equivalent to the 4.0 TimeSpan. See inline Documentation for more detail on syntax. Significant work to enrich design-time experience with TimeSpanPicker.
git checkout -b feature/fooBar
)git commit -am 'Add some fooBar'
)git push origin feature/fooBar
)