-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
daysBetween(a, b)
should return an int
number of days. Adding that number of days to a
should yield b
, e.g.
LocalDate.(
daysBetween(a, b)
|> addDays(_, a)
|> eq(b) //true
);
If the first value is less than the second value, the returned result should be positive (e.g. daysBetween(yesterday, today) == 1
.
Among other things, this could be useful for determining how far into a year a given date is (as a percentage):
let percentOfYear = ymd => {
let beginningOfYear = LocalDate.(ymd |> setMonth(Jan) |> setDay(1));
let between = LocalDate.daysBetween(beginningOfYear, ymd);
Int.toFloat(between) /. Int.toFloat(LocalDate.daysInYear(ymd));
};
Metadata
Metadata
Assignees
Labels
No labels