Skip to content

GorelH/Exceptionless.DateTimeExtensions

 
 

Exceptionless.DateTimeExtensions

Build status NuGet Version NuGet Downloads ![Gitter](https://badges.gitter.im/Join Chat.svg)

DateTimeRange, Business Day and various DateTime, DateTimeOffset, TimeSpan extension methods.

Getting Started (Development)

This package can be installed via the NuGet package manager. If you need help, please contact us via in-app support or open an issue. We’re always here to help if you have any questions!

  1. You will need to have Visual Studio 2013 installed.
  2. Open the Exceptionless.DateTimeExtensions.sln Visual Studio solution file.

Using DateTimeExtensions

Below is a small sampling of the things you can accomplish with DateTimeExtensions, so check it out!

Business Day

Quickly calculate if a datetime is within your hours of business. Check out our unit tests for more usage samples.

var date = DateTime.Now.StartOfDay().AddHours(8);

var day = new BusinessDay(date.Date.DayOfWeek,
    date.Subtract(TimeSpan.FromHours(1)).TimeOfDay,
    date.AddHours(1).TimeOfDay);

bool isDay = day.IsBusinessDay(date);

DateTime Ranges

Quickly work with date ranges. . Check out our unit tests for more usage samples.

var range = DateTimeRange.Parse("yesterday", DateTime.Now);
if (range.Contains(DateTime.Now.Subtract(TimeSpan.FromHours(6)))) {
  //...
}

DateTime Extension methods

Helper methods that makes working with DateTimes easier. Check out the source for all of the extension methods you can use.

using Exceptionless.DateTimeExtensions;

DateTime.Now.ToApproximateAgeString(); // "Just now"
var time = DateTime.Now.StartOfMinute();
var lastWeek = DateTime.Now.LastWeek();
var nextWeek = DateTime.Now.NextWeek();

DateTimeOffset Extension methods

Helper methods that makes working with DateTimeOffsets easier. Check out the source for all of the extension methods you can use.

using Exceptionless.DateTimeExtensions;

DateTimeOffset.Now.ToApproximateAgeString(); // "Just now"
var startOfMonth = DateTimeOffset.Now.ToStartOfMonth();
var endOfMonth = DateTimeOffset.Now.ToEndOfMonth();

Timespan Extension methods

Helper methods that makes working with TimeSpans easier. Check out the source for all of the extension methods you can use.

using Exceptionless.DateTimeExtensions;

var years = TimeSpan.FromHours(6).GetYears();
var totalYears = TimeSpan.FromHours(6).GetTotalYears();

About

DateTimeRange, Business Day and various DateTime, DateTimeOffset, TimeSpan extension methods

Resources

License

Apache-2.0, BSD-3-Clause licenses found

Licenses found

Apache-2.0
LICENSE
BSD-3-Clause
License.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 93.9%
  • PowerShell 6.1%