Skip to content

Commit 41a935a

Browse files
committed
+ DateOnly as Monoid and Zero for TimeOnly
1 parent 1283d35 commit 41a935a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/FSharpPlus/Control/Monoid.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ type Plus =
2626
static member ``+`` (x: array<_> , y , [<Optional>]_mthd: Plus ) = Array.append x y
2727
static member ``+`` (() , () , [<Optional>]_mthd: Plus ) = ()
2828
static member ``+`` (x: bool , y: bool , [<Optional>]_mthd: Plus ) = x <> y
29+
30+
#if NET6_0_OR_GREATER
31+
static member ``+`` (x: DateOnly , y: DateOnly , [<Optional>]_mthd: Plus ) = DateOnly.FromDayNumber (x.DayNumber + y.DayNumber)
32+
#endif
33+
2934
static member ``+`` (x: Set<_> , y , [<Optional>]_mthd: Plus ) = Set.union x y
3035

3136
#if !FABLE_COMPILER

src/FSharpPlus/Control/Numeric.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ type FromInt32 =
9999
static member FromInt32 (_: uint64 , _: FromInt32) = fun (x: int32) -> uint64 x
100100
static member FromInt32 (_: float32 , _: FromInt32) = fun (x: int32) -> float32 x
101101
static member FromInt32 (_: decimal , _: FromInt32) = fun (x: int32) -> decimal x
102+
103+
#if NET6_0_OR_GREATER
104+
static member FromInt32 (_: System.DateOnly , _: FromInt32) = fun (x: int32) -> System.DateOnly.FromDayNumber x
105+
#endif
102106

103107
static member inline Invoke (x: int32) : 'Num =
104108
let inline call_2 (a: ^a, b: ^b) = ((^a or ^b) : (static member FromInt32 : _*_ -> _) b, a)
@@ -133,6 +137,8 @@ type Zero =
133137
inherit Default1
134138

135139
static member Zero (_: System.TimeSpan , _: Zero ) = System.TimeSpan ()
140+
static member Zero (_: System.DateOnly , _: Zero ) = System.DateOnly.MinValue
141+
static member Zero (_: System.TimeOnly , _: Zero ) = System.TimeOnly.MinValue
136142
static member Zero (_: DmStruct , _: Zero ) = Unchecked.defaultof<DmStruct>
137143
static member Zero (_: list<'a> , _: Zero ) = [] : list<'a>
138144
static member Zero (_: option<'a> , _: Zero ) = None : option<'a>

0 commit comments

Comments
 (0)