aboutsummaryrefslogtreecommitdiff
path: root/Aamukampa.Core/Library.fs
diff options
context:
space:
mode:
Diffstat (limited to 'Aamukampa.Core/Library.fs')
-rw-r--r--Aamukampa.Core/Library.fs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Aamukampa.Core/Library.fs b/Aamukampa.Core/Library.fs
new file mode 100644
index 0000000..aa7b7ea
--- /dev/null
+++ b/Aamukampa.Core/Library.fs
@@ -0,0 +1,27 @@
+namespace TJLaskuri.Core
+
+open System
+
+module Domain =
+ // TODO: More precise time: hours, minutes
+ // TODO: Time until service starts
+
+ let getStartDate kontingent =
+ match serviceStartDates.TryGetValue(kontingent) with
+ | true, startDate -> Some startDate
+ | false, _ -> None
+
+ let getEndDate kontingent serviceTime =
+ getStartDate kontingent
+ |> Option.map (fun startDate ->
+ ServiceTime.getDays serviceTime
+ |> fun x -> x - 1 // Count start date as well
+ |> startDate.AddDays)
+
+ let getTimeCompleted kontingent (now : DateTime) =
+ getStartDate kontingent
+ |> Option.map (fun date -> now.AddDays(1) - date)
+
+ let getTimeLeft kontingent serviceTime (now : DateTime) =
+ getEndDate kontingent serviceTime
+ |> Option.map (fun date -> date - now)