Skip to content

Commit

Permalink
fix: Fix duration plugin parsing milliseconds bug (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
allmoviestvshowslistsfilmography28 committed Sep 11, 2020
1 parent db84b1e commit 48ad2c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugin/duration/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MILLISECONDS_A_WEEK, MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND } from '../../constant'
import { MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK } from '../../constant'

const MILLISECONDS_A_YEAR = MILLISECONDS_A_DAY * 365
const MILLISECONDS_A_MONTH = MILLISECONDS_A_DAY * 30
Expand All @@ -12,6 +12,7 @@ const unitToMS = {
hours: MILLISECONDS_A_HOUR,
minutes: MILLISECONDS_A_MINUTE,
seconds: MILLISECONDS_A_SECOND,
milliseconds: 1,
weeks: MILLISECONDS_A_WEEK
}

Expand Down
1 change: 1 addition & 0 deletions test/plugin/duration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ afterEach(() => {

describe('Creating', () => {
it('milliseconds', () => {
expect(dayjs.duration(1, 'ms').toISOString()).toBe('PT0.001S')
expect(dayjs.duration(100).toISOString()).toBe('PT0.1S')
expect(dayjs.duration(1000).toISOString()).toBe('PT1S')
})
Expand Down

0 comments on commit 48ad2c4

Please sign in to comment.