How is time_in_hr_zone calculated?

I was curious if I could replicate the time_in_hr_zone from the FIT file by calculating it directly from the heart_rate signal. Pulling that message out for a sample FIT file gave me these values:

[15.999, 68.0, 418.004, 330.805, 249.424, 535.191, 308.807]

I attempted the calculation quite a few ways but settled on just counting the number of heart_rate samples that fit within each of the given bins defined by hr_zone_high_boundary. That gave me these values:

[ 16, 68, 418, 331, 250, 535, 309]

Which was really close! So then my questions are:

  1. How does the value in the FIT file have so much precision? Assuming typical 1-sec sample rate - I'm curious where the millisecond precision comes from.
  2. Is there any smoothing / averaging done to the heart_rate value before counting time in zone? Any filtering based on number of points in a row in the zone?
  3. If the calculation does just rely on number of samples in a bin - how might this apply to non-uniform time sampling?

Thank you!