TimeSpan.Xt 0.4.0

dotnet add package TimeSpan.Xt --version 0.4.0                
NuGet\Install-Package TimeSpan.Xt -Version 0.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TimeSpan.Xt" Version="0.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TimeSpan.Xt --version 0.4.0                
#r "nuget: TimeSpan.Xt, 0.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TimeSpan.Xt as a Cake Addin
#addin nuget:?package=TimeSpan.Xt&version=0.4.0

// Install TimeSpan.Xt as a Cake Tool
#tool nuget:?package=TimeSpan.Xt&version=0.4.0                

<h1 align="center"> <img width="90" src="logo.png" alt="timext"> </h1>

<p align="center"><h1 style="text-align: center;">TimeSpan.Xt</h1></p>

<p align="center"> <a href="https://github.com/JonasSchubert/TimeSpan.Xt/"><img src="https://img.shields.io/github/stars/JonasSchubert/TimeSpan.Xt.svg"/></a> <a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg"/></a> <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg"/></a> </p>

First of all many thanks to Kizitonwose for the original idea and already awesome library!

This .NET Standard 2.0 library shall help to reduce code like

dotnet add package TimeSpan.Xt
var dayInMillis = 24 * 60 * 60 * 1000;				// Represent a day in milliseconds
var inFiveDays = DateTime.Now + TimeSpan.FromDays(5);
var oneWeekAgo = DateTime.Now - TimeSpan.FromDays(7);

How to use

using TimeSpan.Xt;

var fiveCenturies = 5.Centuries();				// uses precise calculation: 		1 Century == 36500 days
var fiveCenturiesAccumulated = 5.Centuries(true);		// uses accumulated calculation: 	1 Century == 36525 days
var tenDecades = 10.0.Decades();				// uses precise calculation: 		1 Decade == 3650 days
var tenDecadesAccumulated = 10.0.Decades(true);			// uses accumulated calculation: 	1 Decade == 3652.5 days
var twoYears = 2.Years();					// uses precise calculation: 		1 Year == 365 days
var twoYearsAccumulated = 2.Years(true);		        // uses accumulated calculation: 	1 Year == 365.25 days
var oneWeek = 1.Weeks();
var threeDays = 3.Days();
var elevenHours = 11.Hours();
var sixMinutes = 6.Minutes();
var fiftySeconds = 50.Seconds();
var hundredMilliSeconds = 100.Milliseconds();

var oneDayInMillis = 1.Days().InMilliseconds();    		// Converts one day into milliseconds and returns the double value => 86400000
var twoWeeksInHours = 2.Weeks().InHours(); 		    	// Converts two weeks into hours and returns the double value => 336
var thirtyFiveDaysInWeeks = 35.Days().InWeeks(); 		// Converts 35 days into weeks and returns the double value => 5

var addition = 1.Days() + 12.Hours() + 30.Minutes();
var difference = 34.Minutes() - 240.Seconds();
var multiplication = 2.Weeks() * 2;
var division = 2.Minutes() / 2;

var inFiveDays = DateTime.Now + 5.Days();
var yesterday = DateTime.Now - 24.Hours();
var oneWeekAgo = DateTime.Now - 1.Weeks();

Since TimeSpan.Xt is directly interchangable with TimeSpan, it can be used in all places where you would normally use TimeSpan, e.g.

Task.Delay(5.Seconds())

Contributors

<img alt="JonasSchubert" src="https://avatars0.githubusercontent.com/u/21952813?v=4&s=117" width="117"/> <img alt="DenisBiondic" src="https://avatars1.githubusercontent.com/u/3341262?v=4&s=117" width="117"/>
Jonas Schubert Denis Biondic

License

TimeSpan.Xt is distributed under the MIT license. See LICENSE for details.

MIT License

Copyright (c) 2018-2024 JonasSchubert

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.4.0 5,546 2/21/2024