Skip to content

Commit

Permalink
Merge pull request #7 from Thorium/date-convert
Browse files Browse the repository at this point in the history
DateOnly conversion functions
  • Loading branch information
simontreanor committed Jul 4, 2024
2 parents 818c291 + 59e9ab9 commit c49ca7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/DateDay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ module DateDay =
module TrackingDay =
/// create a date from a year, month, and tracking day
let toDate y m td = Date(y, m, min (Date.DaysInMonth(y, m)) td)

#if DATEONLY
module DateOnly =
let FromDate (d:Date) =
DateOnly(d.Year, d.Month, d.Day)

type DateOnly with
member this.ToDate () =
Date(this.Year, this.Month, this.Day)

#endif
1 change: 1 addition & 0 deletions src/FSharp.Finance.Personal.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DefineConstants Condition=" '$(TargetFramework)' == 'net6.0' Or '$(TargetFramework)' == 'net8.0' " >DATEONLY</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
Expand Down

0 comments on commit c49ca7d

Please sign in to comment.