File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ class Duration {
198
198
} else {
199
199
base = this . $d [ pUnit ]
200
200
}
201
- return base === 0 ? 0 : base // a === 0 will be true on both 0 and -0
201
+ return base || 0 // a === 0 will be true on both 0 and -0
202
202
}
203
203
204
204
add ( input , unit , isSubtract ) {
Original file line number Diff line number Diff line change @@ -186,6 +186,12 @@ describe('Add', () => {
186
186
expect ( a . add ( { days : 5 } ) . days ( ) ) . toBe ( 6 )
187
187
} )
188
188
189
+ describe ( 'Add to a dayjs()' , ( ) => {
190
+ const a = dayjs ( )
191
+ const b = dayjs . duration ( { hours : 7 , minutes : 10 } )
192
+ expect ( a . add ( b ) ) . toEqual ( a . add ( 7 , 'hours' ) . add ( 10 , 'minutes' ) )
193
+ } )
194
+
189
195
test ( 'Add duration' , ( ) => {
190
196
const a = dayjs ( '2020-10-01' )
191
197
const days = dayjs . duration ( 2 , 'days' )
You can’t perform that action at this time.
0 commit comments