Skip to content

Reference code has mixed-sign duration errors in some non-ISO calendar difference computations #3159

@ptomato

Description

@ptomato

Reproducers:

const calendar = 'chinese';
const a = new Temporal.PlainDate(2016, 7, 31, calendar);
const b = new Temporal.PlainDate(2017, 7, 31, calendar);
b.since(a, { largestUnit: 'years' });
const calendar = 'hebrew';
const a = new Temporal.PlainDate(1967, 2, 28, calendar);
const b = new Temporal.PlainDate(1968, 3, 1, calendar);
a.until(b, { largestUnit: 'years' });

Crashes with:

file:///.../proposal-temporal/polyfill/lib/ecmascript.mjs:2859
      if (sign !== 0 && propSign !== sign) throw new RangeErrorCtor('mixed-sign values not allowed as duration fields');
                                                 ^

RangeError: mixed-sign values not allowed as duration fields
    at Module.RejectDuration (file:///.../proposal-temporal/polyfill/lib/ecmascript.mjs:2859:50)
    at new Duration (file:///.../proposal-temporal/polyfill/lib/duration.mjs:68:8)
    at TemporalDurationFromInternal (file:///.../proposal-temporal/polyfill/lib/ecmascript.mjs:3009:10)
    at Module.DifferenceTemporalPlainDate (file:///.../proposal-temporal/polyfill/lib/ecmascript.mjs:3769:16)

I haven't investigated these, except to check that they are not regressions from #3156. I'm opening this issue so I don't forget to investigate this at some later time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    non-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions