You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('math order of operations and options',()=>{constbreakoutUnits=(op: any,zdt: Iso.ZonedDateTime,d: any,options: object)=>zdt[op]({years: d.years},options)[op]({months: d.months},options)[op]({weeks: d.weeks},options)[op]({days: d.days},options)[op]({hours: d.hours,minutes: d.minutes,seconds: d.seconds,milliseconds: d.milliseconds},options)it('order of operations: add / none',()=>{constzdt=zonedDateTimeFns.from('2020-01-31T00:00-08:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions=undefinedconstresult=zonedDateTimeFns.add(zdt,d,options)assert.equal(result.toString(),'2020-03-01T00:00:00-08:00[America/Los_Angeles]')assert.equal(breakoutUnits('add',zdt,d,options).toString(),result.toString())})it('order of operations: add / constrain',()=>{constzdt=zonedDateTimeFns.from('2020-01-31T00:00-08:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions={overflow: 'constrain'}constresult=zonedDateTimeFns.add(zdt,d,options)assert.equal(result.toString(),'2020-03-01T00:00:00-08:00[America/Los_Angeles]')assert.equal(breakoutUnits('add',zdt,d,options).toString(),result.toString())})it('order of operations: add / reject',()=>{constzdt=zonedDateTimeFns.from('2020-01-31T00:00-08:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions={overflow: 'reject'}assert.throws(()=>zonedDateTimeFns.add(zdt,d,options),RangeError)})it('order of operations: subtract / none',()=>{constzdt=zonedDateTimeFns.from('2020-03-31T00:00-07:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions=undefinedconstresult=zonedDateTimeFns.subtract(zdt,d,options)assert.equal(result.toString(),'2020-02-28T00:00:00-08:00[America/Los_Angeles]')assert.equal(breakoutUnits('subtract',zdt,d,options).toString(),result.toString())})it('order of operations: subtract / constrain',()=>{constzdt=zonedDateTimeFns.from('2020-03-31T00:00-07:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions={overflow: 'constrain'}constresult=zonedDateTimeFns.subtract(zdt,d,options)assert.equal(result.toString(),'2020-02-28T00:00:00-08:00[America/Los_Angeles]')assert.equal(breakoutUnits('subtract',zdt,d,options).toString(),result.toString())})it('order of operations: subtract / reject',()=>{constzdt=zonedDateTimeFns.from('2020-03-31T00:00-07:00[America/Los_Angeles]')constd=durationFns.from({months: 1,days: 1})constoptions={overflow: 'reject'}assert.throws(()=>zonedDateTimeFns.subtract(zdt,d,options),RangeError)})})
The temporal proposal has tests around the order of operations, but they make use of the fact that the hour, minute, second, etc. fields are directly accessible on their objects which makes it simple to access and test them with different math operators. We should create tests around this.
The text was updated successfully, but these errors were encountered:
The temporal proposal has tests around the order of operations, but they make use of the fact that the hour, minute, second, etc. fields are directly accessible on their objects which makes it simple to access and test them with different math operators. We should create tests around this.
The text was updated successfully, but these errors were encountered: