birl icon indicating copy to clipboard operation
birl copied to clipboard

set_time_of_day does not set monotonic time value

Open michaeljones opened this issue 7 months ago • 2 comments

I came across an issue where I tried to do:

let now = birl.now()
let start_time =
  birl.set_time_of_day(
    now,
    birl.TimeOfDay(hour: 8, minute: 0, second: 0, milli_second: 0),
  )
let diff = birl.difference(now, start_time)

But this always returns Duration(0) because set_time_of_day doesn't seem to change the monotonic_time and difference uses the monotonic_time if it can?

I'm afraid I'm not sure what the solution is. Possibly to set the monotonic time to None if it is not possible to calculate it from the new time of day.

I have worked around it by converting now to an iso8601 string and re-parsing it at which point it doesn't have a monotonic_time so the approach works.

michaeljones avatar Jun 25 '24 15:06 michaeljones