Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/FluentDateTime/FluentDateTime

Allows cleaner DateTime expressions and operations
https://github.com/FluentDateTime/FluentDateTime

Last synced: about 1 month ago
JSON representation

Allows cleaner DateTime expressions and operations

Lists

README

        

# FluentDateTime

[![Build status](https://ci.appveyor.com/api/projects/status/me89rbu5iv976k2q/branch/master?svg=true)](https://ci.appveyor.com/project/SimonCropp/fluentdatetime)
[![NuGet Status](https://img.shields.io/nuget/v/FluentDateTime.svg?label=FluentDateTime&cacheSeconds=86400)](https://www.nuget.org/packages/FluentDateTime/)

Allows cleaner DateTime expressions and operations.

**See [Milestones](../../milestones?state=closed) for release notes.**

Inspired by Ruby DateTime Extensions

* [Extensions To Datetime](http://edgeguides.rubyonrails.org/active_support_core_extensions.html#extensions-to-datetime)
* [Extensions To Time](http://edgeguides.rubyonrails.org/active_support_core_extensions.html#extensions-to-time)

## NuGet

https://nuget.org/packages/FluentDateTime/

## Usage

Here is some examples of use cases

```csharp
// DateTime operations
DateTime.Now - 1.Weeks() - 3.Days() + 14.Minutes()
DateTime.Now + 5.Years()

// Relative DateTime evaluations
3.Days().Ago()
2.Days().Since(DateTime.Now)

// Fluent DateTime estimations
DateTime.Now.NextDay()
DateTime.Now.NextYear()
DateTime.Now.PreviousYear()
DateTime.Now.WeekAfter()
DateTime.Now.Midnight()
DateTime.Now.Noon()

// Current DateTime manipulation
DateTime.Now.SetTime(11, 55, 0)

// DateTime expressions
2022.Mar(23) // (implicitly convertible to DateTime and DateTimeOffset)
2022.March(23).At(10, 26)
```

_See [Unit Tests](https://github.com/FluentDateTime/FluentDateTime/tree/master/src/Tests) in the project for more details._

## Icon

[Calendar](http://thenounproject.com/noun/calendar/#icon-No404) from The Noun Project