Proposal-temporal: Why does the BalanceTime algorithm return a [[Day]] field?

Created on 30 Oct 2019  路  4Comments  路  Source: tc39/proposal-temporal

I'm confused about why we'd div/mod by 24 in BalanceTime. Don't we have some days that are 23 or 25 hours, due to DST? Why not just let there be more than 24 hours?

spec-text

All 4 comments

Sorry, this is clearly correct when it comes to things like Temporal.Time.prototype.plus, minus, etc., where it is used to just wrap around the clock (and the day is discarded). I was wondering especially about how it comes up in Temporal.Time.prototype.difference

It's mostly important for balancing a DateTime. In Temporal.Time.prototype.difference, I think it'll probably always be zero.

The DST thing isn't really a concern because this API requires you to convert either to a UTC context, or to a local (timezone-less) context before making a computation, and then convert back - which is probably good anyways.

@littledan it doesn't return a [[Day]] field, the field should be called [[Days]] because it represents the extra amount of days to be handled. Fixing the naming in the spec/polyfill to better reflect the intent.

Was this page helpful?
0 / 5 - 0 ratings