Timely (or Timely Extensions) is a small C# Library that gives you some shortcuts for Dates and TimeSpan.
With these you can do stuff like 15.February(1996)
or 16.Minutes() + 20.Seconds()
.
With DateExtensions
you can write dates in a natural way. It uses the in Europe commonly used dd-MMM-yyyy
syntax.
To write 15th February 1996 you can write the following:
15.February(1996)
// or
15.Feb(1996)
You can leave the year parameter empty to use the current year.
15.Feb() // => returns "15th February 2017" in the year 2017
DateTime <int:day>.<month>([<year>])
All these methods return a DateTime
instance.
Jan([int? year])
orJanuary([int? year])
Feb([int? year])
orFebruary([int? year])
Mar([int? year])
orMarch([int? year])
Apr([int? year])
orApril([int? year])
May([int? year])
(no short hand here, May is already short enough)Jun([int? year])
orJune([int? year])
Jul([int? year])
orJuly([int? year])
Aug([int? year])
orAugust([int? year])
Sep([int? year])
orSeptember([int? year])
Oct([int? year])
orOctober([int? year])
Nov([int? year])
orNovember([int? year])
Dec([int? year])
orDecember([int? year])
With TimeExtensions
you can create simple TimeSpans from a simple query.
16.Minutes() // => returns a new TimeSpan with 16 minutes
If you want to create a specific TimeSpan with e.g. minutes and seconds you can just add two queries together:
16.Minutes() + 20.Seconds() // => return 16:20 min
TimeSpan <int:amount>.<unit>()
All these methods return a TimeSpan
instance.
Milliseconds()
Seconds()
Minutes()
Hours()
Days()
This project is just a test for me to learn how to write Unit Tests in VS2017 and how to publish a NuGet package.
That being said I hope someone finds this package useful and uses it.
This project is licensed under the MIT License. See LICENSE for more info.