Code Snippet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| open System
type System.Int32 with
member x.Months = DateTime.Today.AddMonths(x) - DateTime.Today
member x.Years = DateTime.Today.AddYears(x) - DateTime.Today
type System.Double with
member x.Days = DateTime.Today.AddDays(x) - DateTime.Today
type System.TimeSpan with
member x.Ago = DateTime.Now.Add(-x)
member x.FromNow = DateTime.Now.Add(x)
member x.FromToday = DateTime.Today.Add(x)
let foo = DateTime.Now - 20 .Years - 0.5 .Days
let bar = 50 .Years.Ago
|
Code output:
References: