javascript-time-ago 2.5.11 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +410 -272
- package/bundle/javascript-time-ago.js +1 -1
- package/bundle/javascript-time-ago.js.map +1 -1
- package/bundle/javascript-time-ago.min.js +1 -1
- package/bundle/javascript-time-ago.min.js.map +1 -1
- package/commonjs/FullDateFormatter.js +72 -0
- package/commonjs/FullDateFormatter.js.map +1 -0
- package/commonjs/FullDateFormatter.test.js +26 -0
- package/commonjs/FullDateFormatter.test.js.map +1 -0
- package/commonjs/LocaleDataStore.js +2 -5
- package/commonjs/LocaleDataStore.js.map +1 -1
- package/commonjs/PropTypes.js +12 -12
- package/commonjs/PropTypes.js.map +1 -1
- package/commonjs/TimeAgo.js +300 -253
- package/commonjs/TimeAgo.js.map +1 -1
- package/commonjs/TimeAgo.test.js +214 -135
- package/commonjs/TimeAgo.test.js.map +1 -1
- package/commonjs/cache.js +7 -25
- package/commonjs/cache.js.map +1 -1
- package/commonjs/cache.test.js +1 -3
- package/commonjs/cache.test.js.map +1 -1
- package/commonjs/isStyleObject.js +9 -9
- package/commonjs/isStyleObject.js.map +1 -1
- package/commonjs/isStyleObject.test.js +1 -3
- package/commonjs/isStyleObject.test.js.map +1 -1
- package/commonjs/locale.js +6 -19
- package/commonjs/locale.js.map +1 -1
- package/commonjs/locale.test.js +2 -11
- package/commonjs/locale.test.js.map +1 -1
- package/commonjs/round.js +2 -5
- package/commonjs/round.js.map +1 -1
- package/commonjs/steps/approximate.js +1 -4
- package/commonjs/steps/approximate.js.map +1 -1
- package/commonjs/steps/approximate.test.js +1 -6
- package/commonjs/steps/approximate.test.js.map +1 -1
- package/commonjs/steps/getStep.js +36 -53
- package/commonjs/steps/getStep.js.map +1 -1
- package/commonjs/steps/getStep.test.js +7 -7
- package/commonjs/steps/getStep.test.js.map +1 -1
- package/commonjs/steps/getStepDenominator.js +2 -5
- package/commonjs/steps/getStepDenominator.js.map +1 -1
- package/commonjs/steps/getStepDenominator.test.js +1 -3
- package/commonjs/steps/getStepDenominator.test.js.map +1 -1
- package/commonjs/steps/getStepMinTime.js +31 -39
- package/commonjs/steps/getStepMinTime.js.map +1 -1
- package/commonjs/steps/getStepMinTime.test.js +1 -3
- package/commonjs/steps/getStepMinTime.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.js +27 -41
- package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.test.js +29 -25
- package/commonjs/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdateForUnit.js +3 -12
- package/commonjs/steps/getTimeToNextUpdateForUnit.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js +1 -7
- package/commonjs/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/commonjs/steps/helpers.js +1 -2
- package/commonjs/steps/helpers.js.map +1 -1
- package/commonjs/steps/helpers.test.js +0 -1
- package/commonjs/steps/helpers.test.js.map +1 -1
- package/commonjs/steps/index.js +1 -6
- package/commonjs/steps/index.js.map +1 -1
- package/commonjs/steps/renameLegacyProperties.js +6 -14
- package/commonjs/steps/renameLegacyProperties.js.map +1 -1
- package/commonjs/steps/renameLegacyProperties.test.js +1 -3
- package/commonjs/steps/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/steps/round.js +1 -2
- package/commonjs/steps/round.js.map +1 -1
- package/commonjs/steps/round.test.js +1 -7
- package/commonjs/steps/round.test.js.map +1 -1
- package/commonjs/steps/units.js +10 -21
- package/commonjs/steps/units.js.map +1 -1
- package/commonjs/style/approximate.js +2 -6
- package/commonjs/style/approximate.js.map +1 -1
- package/commonjs/style/approximateTime.js +2 -6
- package/commonjs/style/approximateTime.js.map +1 -1
- package/commonjs/style/approximateTime.test.js +116 -75
- package/commonjs/style/approximateTime.test.js.map +1 -1
- package/commonjs/style/getStyleByName.js +3 -29
- package/commonjs/style/getStyleByName.js.map +1 -1
- package/commonjs/style/mini.js +9 -6
- package/commonjs/style/mini.js.map +1 -1
- package/commonjs/style/mini.test.js +15 -25
- package/commonjs/style/mini.test.js.map +1 -1
- package/commonjs/style/miniMinute.js +8 -13
- package/commonjs/style/miniMinute.js.map +1 -1
- package/commonjs/style/miniMinute.test.js +11 -17
- package/commonjs/style/miniMinute.test.js.map +1 -1
- package/commonjs/style/miniMinuteNow.js +8 -13
- package/commonjs/style/miniMinuteNow.js.map +1 -1
- package/commonjs/style/miniMinuteNow.test.js +11 -17
- package/commonjs/style/miniMinuteNow.test.js.map +1 -1
- package/commonjs/style/miniNow.js +8 -13
- package/commonjs/style/miniNow.js.map +1 -1
- package/commonjs/style/miniNow.test.js +11 -17
- package/commonjs/style/miniNow.test.js.map +1 -1
- package/commonjs/style/renameLegacyProperties.js +7 -13
- package/commonjs/style/renameLegacyProperties.js.map +1 -1
- package/commonjs/style/renameLegacyProperties.test.js +1 -4
- package/commonjs/style/renameLegacyProperties.test.js.map +1 -1
- package/commonjs/style/round.js +2 -6
- package/commonjs/style/round.js.map +1 -1
- package/commonjs/style/round.test.js +51 -67
- package/commonjs/style/round.test.js.map +1 -1
- package/commonjs/style/roundMinute.js +8 -13
- package/commonjs/style/roundMinute.js.map +1 -1
- package/commonjs/style/roundMinute.test.js +20 -27
- package/commonjs/style/roundMinute.test.js.map +1 -1
- package/commonjs/style/twitter.js +34 -39
- package/commonjs/style/twitter.js.map +1 -1
- package/commonjs/style/twitter.test.js +54 -57
- package/commonjs/style/twitter.test.js.map +1 -1
- package/commonjs/style/twitterFirstMinute.js +10 -15
- package/commonjs/style/twitterFirstMinute.js.map +1 -1
- package/commonjs/style/twitterFirstMinute.test.js +16 -23
- package/commonjs/style/twitterFirstMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinute.js +8 -13
- package/commonjs/style/twitterMinute.js.map +1 -1
- package/commonjs/style/twitterMinute.test.js +20 -25
- package/commonjs/style/twitterMinute.test.js.map +1 -1
- package/commonjs/style/twitterMinuteNow.js +8 -13
- package/commonjs/style/twitterMinuteNow.js.map +1 -1
- package/commonjs/style/twitterMinuteNow.test.js +20 -25
- package/commonjs/style/twitterMinuteNow.test.js.map +1 -1
- package/commonjs/style/twitterNow.js +8 -13
- package/commonjs/style/twitterNow.js.map +1 -1
- package/commonjs/style/twitterNow.test.js +18 -24
- package/commonjs/style/twitterNow.test.js.map +1 -1
- package/full-date-formatter/index.cjs +4 -0
- package/full-date-formatter/index.cjs.js +9 -0
- package/full-date-formatter/index.d.ts +6 -0
- package/full-date-formatter/index.js +1 -0
- package/full-date-formatter/package.json +15 -0
- package/index.cjs +1 -1
- package/index.cjs.js +2 -2
- package/index.d.ts +14 -4
- package/index.js +3 -1
- package/load-all-locales/index.cjs +32 -0
- package/load-all-locales/index.cjs.js +32 -0
- package/load-all-locales/index.js +64 -0
- package/locale/ak/package.json +16 -0
- package/locale/ak.json +267 -0
- package/locale/ak.json.d.ts +4 -0
- package/locale/ak.json.js +267 -0
- package/locale/bal-Latn/package.json +16 -0
- package/locale/bal-Latn.json +240 -0
- package/locale/bal-Latn.json.d.ts +4 -0
- package/locale/bal-Latn.json.js +240 -0
- package/locale/be-tarask/package.json +16 -0
- package/locale/be-tarask.json +259 -0
- package/locale/be-tarask.json.d.ts +4 -0
- package/locale/be-tarask.json.js +259 -0
- package/locale/blo/package.json +16 -0
- package/locale/blo.json +159 -0
- package/locale/blo.json.d.ts +4 -0
- package/locale/blo.json.js +159 -0
- package/locale/bn.json +5 -2
- package/locale/bn.json.js +5 -2
- package/locale/bs.json +8 -2
- package/locale/bs.json.js +8 -2
- package/locale/ccp.json +2 -8
- package/locale/ccp.json.js +2 -8
- package/locale/csw/package.json +16 -0
- package/locale/csw.json +180 -0
- package/locale/csw.json.d.ts +4 -0
- package/locale/csw.json.js +180 -0
- package/locale/cy.json +6 -12
- package/locale/cy.json.js +6 -12
- package/locale/doi/package.json +16 -0
- package/locale/doi.json +159 -0
- package/locale/doi.json.d.ts +4 -0
- package/locale/doi.json.js +159 -0
- package/locale/en-AU.json +12 -12
- package/locale/en-AU.json.js +12 -12
- package/locale/en-CZ/package.json +16 -0
- package/locale/en-CZ.json +219 -0
- package/locale/en-CZ.json.d.ts +4 -0
- package/locale/en-CZ.json.js +219 -0
- package/locale/en-ES/package.json +16 -0
- package/locale/en-ES.json +219 -0
- package/locale/en-ES.json.d.ts +4 -0
- package/locale/en-ES.json.js +219 -0
- package/locale/en-FR/package.json +16 -0
- package/locale/en-FR.json +219 -0
- package/locale/en-FR.json.d.ts +4 -0
- package/locale/en-FR.json.js +219 -0
- package/locale/en-GS/package.json +16 -0
- package/locale/en-GS.json +219 -0
- package/locale/en-GS.json.d.ts +4 -0
- package/locale/en-GS.json.js +219 -0
- package/locale/en-HU/package.json +16 -0
- package/locale/en-HU.json +219 -0
- package/locale/en-HU.json.d.ts +4 -0
- package/locale/en-HU.json.js +219 -0
- package/locale/en-ID/package.json +16 -0
- package/locale/en-ID.json +219 -0
- package/locale/en-ID.json.d.ts +4 -0
- package/locale/en-ID.json.js +219 -0
- package/locale/en-IT/package.json +16 -0
- package/locale/en-IT.json +219 -0
- package/locale/en-IT.json.d.ts +4 -0
- package/locale/en-IT.json.js +219 -0
- package/locale/en-NO/package.json +16 -0
- package/locale/en-NO.json +219 -0
- package/locale/en-NO.json.d.ts +4 -0
- package/locale/en-NO.json.js +219 -0
- package/locale/en-PL/package.json +16 -0
- package/locale/en-PL.json +219 -0
- package/locale/en-PL.json.d.ts +4 -0
- package/locale/en-PL.json.js +219 -0
- package/locale/en-PT/package.json +16 -0
- package/locale/en-PT.json +219 -0
- package/locale/en-PT.json.d.ts +4 -0
- package/locale/en-PT.json.js +219 -0
- package/locale/en-RO/package.json +16 -0
- package/locale/en-RO.json +219 -0
- package/locale/en-RO.json.d.ts +4 -0
- package/locale/en-RO.json.js +219 -0
- package/locale/en-SK/package.json +16 -0
- package/locale/en-SK.json +219 -0
- package/locale/en-SK.json.d.ts +4 -0
- package/locale/en-SK.json.js +219 -0
- package/locale/es-MX.json +12 -9
- package/locale/es-MX.json.js +12 -9
- package/locale/es-SV.json +2 -2
- package/locale/es-SV.json.js +2 -2
- package/locale/eu.json +24 -24
- package/locale/eu.json.js +24 -24
- package/locale/ha.json +119 -65
- package/locale/ha.json.js +119 -65
- package/locale/he.json +0 -6
- package/locale/he.json.js +0 -6
- package/locale/hi-Latn.json +2 -2
- package/locale/hi-Latn.json.js +2 -2
- package/locale/ht/package.json +16 -0
- package/locale/ht.json +207 -0
- package/locale/ht.json.d.ts +4 -0
- package/locale/ht.json.js +207 -0
- package/locale/id.json +1 -1
- package/locale/id.json.js +1 -1
- package/locale/ie/package.json +16 -0
- package/locale/ie.json +159 -0
- package/locale/ie.json.d.ts +4 -0
- package/locale/ie.json.js +159 -0
- package/locale/ig.json +17 -17
- package/locale/ig.json.js +17 -17
- package/locale/ii/package.json +16 -0
- package/locale/ii.json +165 -0
- package/locale/ii.json.d.ts +4 -0
- package/locale/ii.json.js +165 -0
- package/locale/is.json +4 -1
- package/locale/is.json.js +4 -1
- package/locale/kaa/package.json +16 -0
- package/locale/kaa.json +159 -0
- package/locale/kaa.json.d.ts +4 -0
- package/locale/kaa.json.js +159 -0
- package/locale/kok-Latn/package.json +16 -0
- package/locale/kok-Latn.json +159 -0
- package/locale/kok-Latn.json.d.ts +4 -0
- package/locale/kok-Latn.json.js +159 -0
- package/locale/kok.json +8 -8
- package/locale/kok.json.js +8 -8
- package/locale/ks.json +9 -9
- package/locale/ks.json.js +9 -9
- package/locale/ku.json +55 -46
- package/locale/ku.json.js +55 -46
- package/locale/lld/package.json +16 -0
- package/locale/lld.json +291 -0
- package/locale/lld.json.d.ts +4 -0
- package/locale/lld.json.js +291 -0
- package/locale/mi.json +22 -22
- package/locale/mi.json.js +22 -22
- package/locale/ms-Arab/package.json +16 -0
- package/locale/ms-Arab.json +159 -0
- package/locale/ms-Arab.json.d.ts +4 -0
- package/locale/ms-Arab.json.js +159 -0
- package/locale/nb.json +2 -2
- package/locale/nb.json.js +2 -2
- package/locale/ne.json +1 -1
- package/locale/ne.json.js +1 -1
- package/locale/nn.json +4 -4
- package/locale/nn.json.js +4 -4
- package/locale/no.json +2 -2
- package/locale/no.json.js +2 -2
- package/locale/nqo/package.json +16 -0
- package/locale/nqo.json +159 -0
- package/locale/nqo.json.d.ts +4 -0
- package/locale/nqo.json.js +159 -0
- package/locale/om/package.json +16 -0
- package/locale/om.json +213 -0
- package/locale/om.json.d.ts +4 -0
- package/locale/om.json.js +213 -0
- package/locale/or.json +1 -1
- package/locale/or.json.js +1 -1
- package/locale/qu.json +46 -46
- package/locale/qu.json.js +46 -46
- package/locale/rhg/package.json +16 -0
- package/locale/rhg.json +159 -0
- package/locale/rhg.json.d.ts +4 -0
- package/locale/rhg.json.js +159 -0
- package/locale/sl.json +12 -12
- package/locale/sl.json.js +12 -12
- package/locale/sr-Cyrl-BA.json +2 -2
- package/locale/sr-Cyrl-BA.json.js +2 -2
- package/locale/sr-Latn-BA.json +2 -2
- package/locale/sr-Latn-BA.json.js +2 -2
- package/locale/sv.json +1 -1
- package/locale/sv.json.js +1 -1
- package/locale/syr/package.json +16 -0
- package/locale/syr.json +303 -0
- package/locale/syr.json.d.ts +4 -0
- package/locale/syr.json.js +303 -0
- package/locale/ti.json +6 -6
- package/locale/ti.json.js +6 -6
- package/locale/tn/package.json +16 -0
- package/locale/tn.json +159 -0
- package/locale/tn.json.d.ts +4 -0
- package/locale/tn.json.js +159 -0
- package/locale/to.json +26 -26
- package/locale/to.json.js +26 -26
- package/locale/uk.json +1 -1
- package/locale/uk.json.js +1 -1
- package/locale/ur-IN.json +9 -6
- package/locale/ur-IN.json.js +9 -6
- package/locale/vec/package.json +16 -0
- package/locale/vec.json +267 -0
- package/locale/vec.json.d.ts +4 -0
- package/locale/vec.json.js +267 -0
- package/locale/xnr/package.json +16 -0
- package/locale/xnr.json +159 -0
- package/locale/xnr.json.d.ts +4 -0
- package/locale/xnr.json.js +159 -0
- package/locale/yo-BJ.json +17 -17
- package/locale/yo-BJ.json.js +17 -17
- package/locale/yo.json +17 -17
- package/locale/yo.json.js +17 -17
- package/modules/FullDateFormatter.js +67 -0
- package/modules/FullDateFormatter.js.map +1 -0
- package/modules/FullDateFormatter.test.js +22 -0
- package/modules/FullDateFormatter.test.js.map +1 -0
- package/modules/LocaleDataStore.js +2 -3
- package/modules/LocaleDataStore.js.map +1 -1
- package/modules/PropTypes.js +11 -7
- package/modules/PropTypes.js.map +1 -1
- package/modules/TimeAgo.js +299 -237
- package/modules/TimeAgo.js.map +1 -1
- package/modules/TimeAgo.test.js +217 -119
- package/modules/TimeAgo.test.js.map +1 -1
- package/modules/cache.js +6 -22
- package/modules/cache.js.map +1 -1
- package/modules/cache.test.js.map +1 -1
- package/modules/isStyleObject.js +9 -7
- package/modules/isStyleObject.js.map +1 -1
- package/modules/isStyleObject.test.js.map +1 -1
- package/modules/locale.js +6 -16
- package/modules/locale.js.map +1 -1
- package/modules/locale.test.js +0 -4
- package/modules/locale.test.js.map +1 -1
- package/modules/round.js +2 -3
- package/modules/round.js.map +1 -1
- package/modules/steps/approximate.js +6 -2
- package/modules/steps/approximate.js.map +1 -1
- package/modules/steps/approximate.test.js +0 -2
- package/modules/steps/approximate.test.js.map +1 -1
- package/modules/steps/getStep.js +36 -48
- package/modules/steps/getStep.js.map +1 -1
- package/modules/steps/getStep.test.js +6 -2
- package/modules/steps/getStep.test.js.map +1 -1
- package/modules/steps/getStepDenominator.js +2 -3
- package/modules/steps/getStepDenominator.js.map +1 -1
- package/modules/steps/getStepDenominator.test.js.map +1 -1
- package/modules/steps/getStepMinTime.js +31 -36
- package/modules/steps/getStepMinTime.js.map +1 -1
- package/modules/steps/getStepMinTime.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.js +28 -32
- package/modules/steps/getTimeToNextUpdate.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.test.js +27 -18
- package/modules/steps/getTimeToNextUpdate.test.js.map +1 -1
- package/modules/steps/getTimeToNextUpdateForUnit.js +4 -10
- package/modules/steps/getTimeToNextUpdateForUnit.js.map +1 -1
- package/modules/steps/getTimeToNextUpdateForUnit.test.js +0 -4
- package/modules/steps/getTimeToNextUpdateForUnit.test.js.map +1 -1
- package/modules/steps/helpers.js +1 -1
- package/modules/steps/helpers.js.map +1 -1
- package/modules/steps/helpers.test.js.map +1 -1
- package/modules/steps/index.js +2 -1
- package/modules/steps/index.js.map +1 -1
- package/modules/steps/renameLegacyProperties.js +6 -13
- package/modules/steps/renameLegacyProperties.js.map +1 -1
- package/modules/steps/renameLegacyProperties.test.js.map +1 -1
- package/modules/steps/round.js.map +1 -1
- package/modules/steps/round.test.js +0 -3
- package/modules/steps/round.test.js.map +1 -1
- package/modules/steps/units.js +5 -9
- package/modules/steps/units.js.map +1 -1
- package/modules/style/approximate.js +5 -1
- package/modules/style/approximate.js.map +1 -1
- package/modules/style/approximateTime.js +6 -2
- package/modules/style/approximateTime.js.map +1 -1
- package/modules/style/approximateTime.test.js +115 -70
- package/modules/style/approximateTime.test.js.map +1 -1
- package/modules/style/getStyleByName.js +4 -17
- package/modules/style/getStyleByName.js.map +1 -1
- package/modules/style/mini.js +8 -4
- package/modules/style/mini.js.map +1 -1
- package/modules/style/mini.test.js +14 -20
- package/modules/style/mini.test.js.map +1 -1
- package/modules/style/miniMinute.js +6 -6
- package/modules/style/miniMinute.js.map +1 -1
- package/modules/style/miniMinute.test.js +10 -12
- package/modules/style/miniMinute.test.js.map +1 -1
- package/modules/style/miniMinuteNow.js +6 -6
- package/modules/style/miniMinuteNow.js.map +1 -1
- package/modules/style/miniMinuteNow.test.js +10 -12
- package/modules/style/miniMinuteNow.test.js.map +1 -1
- package/modules/style/miniNow.js +6 -6
- package/modules/style/miniNow.js.map +1 -1
- package/modules/style/miniNow.test.js +10 -12
- package/modules/style/miniNow.test.js.map +1 -1
- package/modules/style/renameLegacyProperties.js +8 -10
- package/modules/style/renameLegacyProperties.js.map +1 -1
- package/modules/style/renameLegacyProperties.test.js +0 -1
- package/modules/style/renameLegacyProperties.test.js.map +1 -1
- package/modules/style/round.js +3 -2
- package/modules/style/round.js.map +1 -1
- package/modules/style/round.test.js +50 -62
- package/modules/style/round.test.js.map +1 -1
- package/modules/style/roundMinute.js +8 -7
- package/modules/style/roundMinute.js.map +1 -1
- package/modules/style/roundMinute.test.js +19 -22
- package/modules/style/roundMinute.test.js.map +1 -1
- package/modules/style/twitter.js +36 -33
- package/modules/style/twitter.js.map +1 -1
- package/modules/style/twitter.test.js +53 -52
- package/modules/style/twitter.test.js.map +1 -1
- package/modules/style/twitterFirstMinute.js +8 -7
- package/modules/style/twitterFirstMinute.js.map +1 -1
- package/modules/style/twitterFirstMinute.test.js +15 -18
- package/modules/style/twitterFirstMinute.test.js.map +1 -1
- package/modules/style/twitterMinute.js +6 -6
- package/modules/style/twitterMinute.js.map +1 -1
- package/modules/style/twitterMinute.test.js +19 -20
- package/modules/style/twitterMinute.test.js.map +1 -1
- package/modules/style/twitterMinuteNow.js +6 -6
- package/modules/style/twitterMinuteNow.js.map +1 -1
- package/modules/style/twitterMinuteNow.test.js +19 -20
- package/modules/style/twitterMinuteNow.test.js.map +1 -1
- package/modules/style/twitterNow.js +6 -6
- package/modules/style/twitterNow.js.map +1 -1
- package/modules/style/twitterNow.test.js +17 -19
- package/modules/style/twitterNow.test.js.map +1 -1
- package/package.json +275 -13
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSecondsInUnit } from './units.js';
|
|
2
2
|
import { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Gets the time to next update for a step with a time unit defined.
|
|
5
6
|
* @param {string} unit
|
|
@@ -8,23 +9,19 @@ import { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js';
|
|
|
8
9
|
* @param {string} [options.round] — (undocumented) Rounding mechanism.
|
|
9
10
|
* @return {number} [timeToNextUpdate]
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
12
|
export default function getTimeToNextUpdateForUnit(unit, timestamp, _ref) {
|
|
13
13
|
var now = _ref.now,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
round = _ref.round;
|
|
16
15
|
// For some units, like "now", there's no defined amount of seconds in them.
|
|
17
16
|
if (!getSecondsInUnit(unit)) {
|
|
18
17
|
// If there's no amount of seconds defined for this unit
|
|
19
18
|
// then the update interval can't be determined reliably.
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
var unitDenominator = getSecondsInUnit(unit) * 1000;
|
|
24
22
|
var future = timestamp > now;
|
|
25
23
|
var preciseAmount = Math.abs(timestamp - now);
|
|
26
24
|
var roundedAmount = getRoundFunction(round)(preciseAmount / unitDenominator) * unitDenominator;
|
|
27
|
-
|
|
28
25
|
if (future) {
|
|
29
26
|
if (roundedAmount > 0) {
|
|
30
27
|
// Amount decreases with time.
|
|
@@ -34,16 +31,13 @@ export default function getTimeToNextUpdateForUnit(unit, timestamp, _ref) {
|
|
|
34
31
|
// when "future" changes to "past".
|
|
35
32
|
return preciseAmount - roundedAmount + 1;
|
|
36
33
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
}
|
|
35
|
+
// Amount increases with time.
|
|
40
36
|
return -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator);
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
function getDiffToNextRoundedNumber(round, unitDenominator) {
|
|
44
39
|
return getDiffRatioToNextRoundedNumber(round) * unitDenominator;
|
|
45
40
|
}
|
|
46
|
-
|
|
47
41
|
function getDiffToPreviousRoundedNumber(round, unitDenominator) {
|
|
48
42
|
return (1 - getDiffRatioToNextRoundedNumber(round)) * unitDenominator + 1;
|
|
49
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdateForUnit.js","names":["getSecondsInUnit","getRoundFunction","getDiffRatioToNextRoundedNumber","getTimeToNextUpdateForUnit","unit","timestamp","now","round","unitDenominator","future","preciseAmount","Math","abs","roundedAmount","getDiffToPreviousRoundedNumber","getDiffToNextRoundedNumber"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\n/**\r\n * Gets the time to next update for a step with a time unit defined.\r\n * @param {string} unit\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {number} options.now\r\n * @param {string} [options.round] — (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate]\r\n */\r\nexport default function getTimeToNextUpdateForUnit(unit, timestamp, { now, round }) {\r\n\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\tif (!getSecondsInUnit(unit)) {\r\n\t\t// If there's no amount of seconds defined for this unit\r\n\t\t// then the update interval can't be determined reliably.\r\n\t\treturn\r\n\t}\r\n\tconst unitDenominator = getSecondsInUnit(unit) * 1000\r\n\tconst future = timestamp > now\r\n\tconst preciseAmount = Math.abs(timestamp - now)\r\n\tconst roundedAmount = getRoundFunction(round)(preciseAmount / unitDenominator) * unitDenominator\r\n\tif (future) {\r\n\t\tif (roundedAmount > 0) {\r\n\t\t\t// Amount decreases with time.\r\n\t\t\treturn (preciseAmount - roundedAmount) +\r\n\t\t\t\tgetDiffToPreviousRoundedNumber(round, unitDenominator)\r\n\t\t} else {\r\n\t\t\t// Refresh right after the zero point,\r\n\t\t\t// when \"future\" changes to \"past\".\r\n\t\t\treturn (preciseAmount - roundedAmount) + 1\r\n\t\t}\r\n\t}\r\n \t// Amount increases with time.\r\n\treturn -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator)\r\n}\r\n\r\nfunction getDiffToNextRoundedNumber(round, unitDenominator) {\r\n\treturn getDiffRatioToNextRoundedNumber(round) * unitDenominator\r\n}\r\n\r\nfunction getDiffToPreviousRoundedNumber(round, unitDenominator) {\r\n\treturn (1 - getDiffRatioToNextRoundedNumber(round)) * unitDenominator + 1\r\n}"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdateForUnit.js","names":["getSecondsInUnit","getRoundFunction","getDiffRatioToNextRoundedNumber","getTimeToNextUpdateForUnit","unit","timestamp","_ref","now","round","unitDenominator","future","preciseAmount","Math","abs","roundedAmount","getDiffToPreviousRoundedNumber","getDiffToNextRoundedNumber"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.js"],"sourcesContent":["import { getSecondsInUnit } from './units.js'\r\nimport { getRoundFunction, getDiffRatioToNextRoundedNumber } from '../round.js'\r\n\r\n/**\r\n * Gets the time to next update for a step with a time unit defined.\r\n * @param {string} unit\r\n * @param {number} date — The date passed to `.format()`, converted to a timestamp.\r\n * @param {number} options.now\r\n * @param {string} [options.round] — (undocumented) Rounding mechanism.\r\n * @return {number} [timeToNextUpdate]\r\n */\r\nexport default function getTimeToNextUpdateForUnit(unit, timestamp, { now, round }) {\r\n\t// For some units, like \"now\", there's no defined amount of seconds in them.\r\n\tif (!getSecondsInUnit(unit)) {\r\n\t\t// If there's no amount of seconds defined for this unit\r\n\t\t// then the update interval can't be determined reliably.\r\n\t\treturn\r\n\t}\r\n\tconst unitDenominator = getSecondsInUnit(unit) * 1000\r\n\tconst future = timestamp > now\r\n\tconst preciseAmount = Math.abs(timestamp - now)\r\n\tconst roundedAmount = getRoundFunction(round)(preciseAmount / unitDenominator) * unitDenominator\r\n\tif (future) {\r\n\t\tif (roundedAmount > 0) {\r\n\t\t\t// Amount decreases with time.\r\n\t\t\treturn (preciseAmount - roundedAmount) +\r\n\t\t\t\tgetDiffToPreviousRoundedNumber(round, unitDenominator)\r\n\t\t} else {\r\n\t\t\t// Refresh right after the zero point,\r\n\t\t\t// when \"future\" changes to \"past\".\r\n\t\t\treturn (preciseAmount - roundedAmount) + 1\r\n\t\t}\r\n\t}\r\n \t// Amount increases with time.\r\n\treturn -(preciseAmount - roundedAmount) + getDiffToNextRoundedNumber(round, unitDenominator)\r\n}\r\n\r\nfunction getDiffToNextRoundedNumber(round, unitDenominator) {\r\n\treturn getDiffRatioToNextRoundedNumber(round) * unitDenominator\r\n}\r\n\r\nfunction getDiffToPreviousRoundedNumber(round, unitDenominator) {\r\n\treturn (1 - getDiffRatioToNextRoundedNumber(round)) * unitDenominator + 1\r\n}"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,YAAY;AAC7C,SAASC,gBAAgB,EAAEC,+BAA+B,QAAQ,aAAa;;AAE/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,0BAA0BA,CAACC,IAAI,EAAEC,SAAS,EAAAC,IAAA,EAAkB;EAAA,IAAdC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,KAAK,GAAAF,IAAA,CAALE,KAAK;EAC/E;EACA,IAAI,CAACR,gBAAgB,CAACI,IAAI,CAAC,EAAE;IAC5B;IACA;IACA;EACD;EACA,IAAMK,eAAe,GAAGT,gBAAgB,CAACI,IAAI,CAAC,GAAG,IAAI;EACrD,IAAMM,MAAM,GAAGL,SAAS,GAAGE,GAAG;EAC9B,IAAMI,aAAa,GAAGC,IAAI,CAACC,GAAG,CAACR,SAAS,GAAGE,GAAG,CAAC;EAC/C,IAAMO,aAAa,GAAGb,gBAAgB,CAACO,KAAK,CAAC,CAACG,aAAa,GAAGF,eAAe,CAAC,GAAGA,eAAe;EAChG,IAAIC,MAAM,EAAE;IACX,IAAII,aAAa,GAAG,CAAC,EAAE;MACtB;MACA,OAAQH,aAAa,GAAGG,aAAa,GACpCC,8BAA8B,CAACP,KAAK,EAAEC,eAAe,CAAC;IACxD,CAAC,MAAM;MACN;MACA;MACA,OAAQE,aAAa,GAAGG,aAAa,GAAI,CAAC;IAC3C;EACD;EACC;EACD,OAAO,EAAEH,aAAa,GAAGG,aAAa,CAAC,GAAGE,0BAA0B,CAACR,KAAK,EAAEC,eAAe,CAAC;AAC7F;AAEA,SAASO,0BAA0BA,CAACR,KAAK,EAAEC,eAAe,EAAE;EAC3D,OAAOP,+BAA+B,CAACM,KAAK,CAAC,GAAGC,eAAe;AAChE;AAEA,SAASM,8BAA8BA,CAACP,KAAK,EAAEC,eAAe,EAAE;EAC/D,OAAO,CAAC,CAAC,GAAGP,+BAA+B,CAACM,KAAK,CAAC,IAAIC,eAAe,GAAG,CAAC;AAC1E","ignoreList":[]}
|
|
@@ -17,7 +17,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
17
17
|
now: 0
|
|
18
18
|
}).should.equal(expected * 1000 + (addOneMs ? 1 : 0));
|
|
19
19
|
};
|
|
20
|
-
|
|
21
20
|
test(9, 0.5);
|
|
22
21
|
test(9.1, 0.6);
|
|
23
22
|
test(9.4, 0.9);
|
|
@@ -39,7 +38,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
39
38
|
now: 0
|
|
40
39
|
}).should.equal(expected * 1000);
|
|
41
40
|
};
|
|
42
|
-
|
|
43
41
|
test(10, 0.5);
|
|
44
42
|
test(9.9, 0.6);
|
|
45
43
|
test(9.5, 1);
|
|
@@ -61,7 +59,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
61
59
|
round: 'floor'
|
|
62
60
|
}).should.equal(expected * 1000 + (addOneMs ? 1 : 0));
|
|
63
61
|
};
|
|
64
|
-
|
|
65
62
|
test(9, 0);
|
|
66
63
|
test(9.1, 0.1);
|
|
67
64
|
test(9.4, 0.4);
|
|
@@ -83,7 +80,6 @@ describe('getTimeToNextUpdateForUnit', function () {
|
|
|
83
80
|
round: 'floor'
|
|
84
81
|
}).should.equal(expected * 1000);
|
|
85
82
|
};
|
|
86
|
-
|
|
87
83
|
test(10, 1);
|
|
88
84
|
test(9.9, 0.1);
|
|
89
85
|
test(9.5, 0.5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTimeToNextUpdateForUnit.test.js","names":["getTimeToNextUpdateForUnit","describe","it","expect","to","be","undefined","Date","now","should","equal","test","seconds","expected","addOneMs","round"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.test.js"],"sourcesContent":["import getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\n\r\ndescribe('getTimeToNextUpdateForUnit', () => {\r\n\tit('should return undefined for unknown units', () => {\r\n\t\texpect(getTimeToNextUpdateForUnit('now', 0, {})).to.be.undefined\r\n\t})\r\n\r\n\tit('should support Date argument', () => {\r\n\t\tgetTimeToNextUpdateForUnit('second', new Date(0), {\r\n\t\t\t// future: false,\r\n\t\t\tnow: 0\r\n\t\t}).should.equal(500)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0.5)\r\n\t\ttest(9.1, 0.6)\r\n\t\ttest(9.4, 0.9)\r\n\t\ttest(9.5, 0)\r\n\t\ttest(9.9, 0.4)\r\n\t\ttest(10, 0.5)\r\n\r\n\t\ttest(1.1, 0.6)\r\n\t\ttest(1, 0.5)\r\n\t\ttest(0.9, 0.4)\r\n\t\ttest(0.5, 0)\r\n\t\ttest(0.4, 0.4)\r\n\t\ttest(0, 0.5, false)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (past)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 0.5)\r\n\t\ttest(9.9, 0.6)\r\n\t\ttest(9.5, 1)\r\n\t\ttest(9.4, 0.1)\r\n\t\ttest(9.1, 0.4)\r\n\t\ttest(9, 0.5)\r\n\r\n\t\ttest(0, 0.5, false)\r\n\t\ttest(0.5, 1, false)\r\n\t\ttest(0.9, 0.6, false)\r\n\t\ttest(1, 0.5, false)\r\n\t\ttest(1.1, 0.4, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0)\r\n\t\ttest(9.1, 0.1)\r\n\t\ttest(9.4, 0.4)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.9, 0.9)\r\n\t\ttest(10, 0)\r\n\r\n\t\ttest(1.1, 0.1)\r\n\t\ttest(1, 0)\r\n\t\ttest(0.9, 0.9)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.1, 0.1)\r\n\t\ttest(0, 1, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (past)', () => {\r\n\t\tconst test = (seconds, expected) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 1)\r\n\t\ttest(9.9, 0.1)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.4, 0.6)\r\n\t\ttest(9.1, 0.9)\r\n\t\ttest(9, 1)\r\n\r\n\t\ttest(0, 1)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.9, 0.1)\r\n\t\ttest(1, 1)\r\n\t\ttest(1.1, 0.9)\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"getTimeToNextUpdateForUnit.test.js","names":["getTimeToNextUpdateForUnit","describe","it","expect","to","be","undefined","Date","now","should","equal","test","seconds","expected","addOneMs","arguments","length","round"],"sources":["../../source/steps/getTimeToNextUpdateForUnit.test.js"],"sourcesContent":["import getTimeToNextUpdateForUnit from './getTimeToNextUpdateForUnit.js'\r\n\r\ndescribe('getTimeToNextUpdateForUnit', () => {\r\n\tit('should return undefined for unknown units', () => {\r\n\t\texpect(getTimeToNextUpdateForUnit('now', 0, {})).to.be.undefined\r\n\t})\r\n\r\n\tit('should support Date argument', () => {\r\n\t\tgetTimeToNextUpdateForUnit('second', new Date(0), {\r\n\t\t\t// future: false,\r\n\t\t\tnow: 0\r\n\t\t}).should.equal(500)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0.5)\r\n\t\ttest(9.1, 0.6)\r\n\t\ttest(9.4, 0.9)\r\n\t\ttest(9.5, 0)\r\n\t\ttest(9.9, 0.4)\r\n\t\ttest(10, 0.5)\r\n\r\n\t\ttest(1.1, 0.6)\r\n\t\ttest(1, 0.5)\r\n\t\ttest(0.9, 0.4)\r\n\t\ttest(0.5, 0)\r\n\t\ttest(0.4, 0.4)\r\n\t\ttest(0, 0.5, false)\r\n\t})\r\n\r\n\tit('should get time to next update for unit (past)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 0.5)\r\n\t\ttest(9.9, 0.6)\r\n\t\ttest(9.5, 1)\r\n\t\ttest(9.4, 0.1)\r\n\t\ttest(9.1, 0.4)\r\n\t\ttest(9, 0.5)\r\n\r\n\t\ttest(0, 0.5, false)\r\n\t\ttest(0.5, 1, false)\r\n\t\ttest(0.9, 0.6, false)\r\n\t\ttest(1, 0.5, false)\r\n\t\ttest(1.1, 0.4, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (future)', () => {\r\n\t\tconst test = (seconds, expected, addOneMs = true) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', seconds * 1000, {\r\n\t\t\t\t// future: true,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000 + (addOneMs ? 1 : 0))\r\n\t\t}\r\n\r\n\t\ttest(9, 0)\r\n\t\ttest(9.1, 0.1)\r\n\t\ttest(9.4, 0.4)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.9, 0.9)\r\n\t\ttest(10, 0)\r\n\r\n\t\ttest(1.1, 0.1)\r\n\t\ttest(1, 0)\r\n\t\ttest(0.9, 0.9)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.1, 0.1)\r\n\t\ttest(0, 1, false)\r\n\t})\r\n\r\n\tit('should support \"floor\" rounding (past)', () => {\r\n\t\tconst test = (seconds, expected) => {\r\n\t\t\tgetTimeToNextUpdateForUnit('second', -1 * seconds * 1000, {\r\n\t\t\t\t// future: false,\r\n\t\t\t\tnow: 0,\r\n\t\t\t\tround: 'floor'\r\n\t\t\t}).should.equal(expected * 1000)\r\n\t\t}\r\n\r\n\t\ttest(10, 1)\r\n\t\ttest(9.9, 0.1)\r\n\t\ttest(9.5, 0.5)\r\n\t\ttest(9.4, 0.6)\r\n\t\ttest(9.1, 0.9)\r\n\t\ttest(9, 1)\r\n\r\n\t\ttest(0, 1)\r\n\t\ttest(0.5, 0.5)\r\n\t\ttest(0.9, 0.1)\r\n\t\ttest(1, 1)\r\n\t\ttest(1.1, 0.9)\r\n\t})\r\n})"],"mappings":"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jC,CAAC;IAEDF,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACXA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAEVA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACVA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;IACdA,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IACVA,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;EACf,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/modules/steps/helpers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["getDate","value","Date"],"sources":["../../source/steps/helpers.js"],"sourcesContent":["// Looks like this one's deprecated.\r\n// /**\r\n// * Returns a step corresponding to the unit.\r\n// * @param {Object[]} steps\r\n// * @param {string} unit\r\n// * @return {?Object}\r\n// */\r\n// export function getStepForUnit(steps, unit) {\r\n// \tfor (const step of steps) {\r\n// \t\tif (step.unit === unit) {\r\n// \t\t\treturn step\r\n// \t\t}\r\n// \t}\r\n// }\r\n\r\n// Looks like this one won't be used in the next major version.\r\n/**\r\n * Converts value to a `Date`\r\n * @param {(number|Date)} value\r\n * @return {Date}\r\n */\r\nexport function getDate(value) {\r\n\treturn value instanceof Date ? value : new Date(value)\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["getDate","value","Date"],"sources":["../../source/steps/helpers.js"],"sourcesContent":["// Looks like this one's deprecated.\r\n// /**\r\n// * Returns a step corresponding to the unit.\r\n// * @param {Object[]} steps\r\n// * @param {string} unit\r\n// * @return {?Object}\r\n// */\r\n// export function getStepForUnit(steps, unit) {\r\n// \tfor (const step of steps) {\r\n// \t\tif (step.unit === unit) {\r\n// \t\t\treturn step\r\n// \t\t}\r\n// \t}\r\n// }\r\n\r\n// Looks like this one won't be used in the next major version.\r\n/**\r\n * Converts value to a `Date`\r\n * @param {(number|Date)} value\r\n * @return {Date}\r\n */\r\nexport function getDate(value) {\r\n\treturn value instanceof Date ? value : new Date(value)\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,OAAOA,CAACC,KAAK,EAAE;EAC9B,OAAOA,KAAK,YAAYC,IAAI,GAAGD,KAAK,GAAG,IAAIC,IAAI,CAACD,KAAK,CAAC;AACvD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.test.js","names":["getDate","describe","it","today","Date","getTime","should","equal"],"sources":["../../source/steps/helpers.test.js"],"sourcesContent":["import { getDate } from './helpers.js'\r\n\r\ndescribe('steps/helpers', () => {\r\n\tit('should convert value to Date', () => {\r\n\t\tconst today = new Date()\r\n\t\tgetDate(today.getTime()).getTime().should.equal(today.getTime())\r\n\t\tgetDate(today).getTime().should.equal(today.getTime())\r\n\t})\r\n})"],"mappings":"AAAA,SAASA,
|
|
1
|
+
{"version":3,"file":"helpers.test.js","names":["getDate","describe","it","today","Date","getTime","should","equal"],"sources":["../../source/steps/helpers.test.js"],"sourcesContent":["import { getDate } from './helpers.js'\r\n\r\ndescribe('steps/helpers', () => {\r\n\tit('should convert value to Date', () => {\r\n\t\tconst today = new Date()\r\n\t\tgetDate(today.getTime()).getTime().should.equal(today.getTime())\r\n\t\tgetDate(today).getTime().should.equal(today.getTime())\r\n\t})\r\n})"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc;AAEtCC,QAAQ,CAAC,eAAe,EAAE,YAAM;EAC/BC,EAAE,CAAC,8BAA8B,EAAE,YAAM;IACxC,IAAMC,KAAK,GAAG,IAAIC,IAAI,CAAC,CAAC;IACxBJ,OAAO,CAACG,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC,CAACA,OAAO,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAACJ,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;IAChEL,OAAO,CAACG,KAAK,CAAC,CAACE,OAAO,CAAC,CAAC,CAACC,MAAM,CAACC,KAAK,CAACJ,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC;EACvD,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/modules/steps/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// "convenient" is a legacy name of "approximate" steps.
|
|
2
|
-
export { default as approximate, default as convenient } from './approximate.js';
|
|
2
|
+
export { default as approximate, default as convenient } from './approximate.js';
|
|
3
3
|
|
|
4
|
+
// "canonical" is a legacy name of "round" steps.
|
|
4
5
|
export { default as round, default as canonical } from './round.js';
|
|
5
6
|
export { minute, hour, day, week, month, year } from './units.js';
|
|
6
7
|
export { getDate } from './helpers.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","approximate","convenient","round","canonical","minute","hour","day","week","month","year","getDate"],"sources":["../../source/steps/index.js"],"sourcesContent":["// \"convenient\" is a legacy name of \"approximate\" steps.\r\nexport { default as approximate, default as convenient } from './approximate.js'\r\n\r\n// \"canonical\" is a legacy name of \"round\" steps.\r\nexport { default as round, default as canonical } from './round.js'\r\n\r\nexport {\r\n\tminute,\r\n\thour,\r\n\tday,\r\n\tweek,\r\n\tmonth,\r\n\tyear\r\n} from './units.js'\r\n\r\nexport {\r\n\tgetDate\r\n} from './helpers.js'"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","approximate","convenient","round","canonical","minute","hour","day","week","month","year","getDate"],"sources":["../../source/steps/index.js"],"sourcesContent":["// \"convenient\" is a legacy name of \"approximate\" steps.\r\nexport { default as approximate, default as convenient } from './approximate.js'\r\n\r\n// \"canonical\" is a legacy name of \"round\" steps.\r\nexport { default as round, default as canonical } from './round.js'\r\n\r\nexport {\r\n\tminute,\r\n\thour,\r\n\tday,\r\n\tweek,\r\n\tmonth,\r\n\tyear\r\n} from './units.js'\r\n\r\nexport {\r\n\tgetDate\r\n} from './helpers.js'"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,WAAW,EAAED,OAAO,IAAIE,UAAU,QAAQ,kBAAkB;;AAEhF;AACA,SAASF,OAAO,IAAIG,KAAK,EAAEH,OAAO,IAAII,SAAS,QAAQ,YAAY;AAEnE,SACCC,MAAM,EACNC,IAAI,EACJC,GAAG,EACHC,IAAI,EACJC,KAAK,EACLC,IAAI,QACE,YAAY;AAEnB,SACCC,OAAO,QACD,cAAc","ignoreList":[]}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
7
|
// This function is only used for backwards compatibility
|
|
10
8
|
// with legacy code that uses the older versions of this library.
|
|
11
9
|
export default function (step_) {
|
|
12
10
|
var step = _objectSpread({}, step_);
|
|
13
|
-
|
|
14
11
|
if (step.minTime !== undefined) {
|
|
15
12
|
if (_typeof(step.minTime) === 'object') {
|
|
16
13
|
for (var _i = 0, _Object$keys = Object.keys(step.minTime); _i < _Object$keys.length; _i++) {
|
|
17
14
|
var key = _Object$keys[_i];
|
|
18
|
-
|
|
19
15
|
if (key === 'default') {
|
|
20
16
|
step.threshold = step.minTime["default"];
|
|
21
17
|
} else {
|
|
@@ -25,15 +21,12 @@ export default function (step_) {
|
|
|
25
21
|
} else {
|
|
26
22
|
step.threshold = step.minTime;
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
delete step.minTime;
|
|
30
25
|
}
|
|
31
|
-
|
|
32
26
|
if (step.formatAs) {
|
|
33
27
|
step.unit = step.formatAs;
|
|
34
28
|
delete step.formatAs;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
30
|
return step;
|
|
38
31
|
}
|
|
39
32
|
//# sourceMappingURL=renameLegacyProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameLegacyProperties.js","names":["step_","step","minTime","undefined","Object","keys","key","threshold","formatAs","unit"],"sources":["../../source/steps/renameLegacyProperties.js"],"sourcesContent":["// This function is only used for backwards compatibility\r\n// with legacy code that uses the older versions of this library.\r\nexport default function(step_) {\r\n\tconst step = { ...step_ }\r\n\tif (step.minTime !== undefined) {\r\n\t\tif (typeof step.minTime === 'object') {\r\n\t\t\tfor (const key of Object.keys(step.minTime)) {\r\n\t\t\t\tif (key === 'default') {\r\n\t\t\t\t\tstep.threshold = step.minTime.default\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstep[`threshold_for_${key}`] = step.minTime[key]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tstep.threshold = step.minTime\r\n\t\t}\r\n\t\tdelete step.minTime\r\n\t}\r\n\tif (step.formatAs) {\r\n\t\tstep.unit = step.formatAs\r\n\t\tdelete step.formatAs\r\n\t}\r\n\treturn step\r\n}"],"mappings":"
|
|
1
|
+
{"version":3,"file":"renameLegacyProperties.js","names":["step_","step","_objectSpread","minTime","undefined","_typeof","_i","_Object$keys","Object","keys","length","key","threshold","concat","formatAs","unit"],"sources":["../../source/steps/renameLegacyProperties.js"],"sourcesContent":["// This function is only used for backwards compatibility\r\n// with legacy code that uses the older versions of this library.\r\nexport default function(step_) {\r\n\tconst step = { ...step_ }\r\n\tif (step.minTime !== undefined) {\r\n\t\tif (typeof step.minTime === 'object') {\r\n\t\t\tfor (const key of Object.keys(step.minTime)) {\r\n\t\t\t\tif (key === 'default') {\r\n\t\t\t\t\tstep.threshold = step.minTime.default\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstep[`threshold_for_${key}`] = step.minTime[key]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tstep.threshold = step.minTime\r\n\t\t}\r\n\t\tdelete step.minTime\r\n\t}\r\n\tif (step.formatAs) {\r\n\t\tstep.unit = step.formatAs\r\n\t\tdelete step.formatAs\r\n\t}\r\n\treturn step\r\n}"],"mappings":";;;;;;AAAA;AACA;AACA,eAAe,UAASA,KAAK,EAAE;EAC9B,IAAMC,IAAI,GAAAC,aAAA,KAAQF,KAAK,CAAE;EACzB,IAAIC,IAAI,CAACE,OAAO,KAAKC,SAAS,EAAE;IAC/B,IAAIC,OAAA,CAAOJ,IAAI,CAACE,OAAO,MAAK,QAAQ,EAAE;MACrC,SAAAG,EAAA,MAAAC,YAAA,GAAkBC,MAAM,CAACC,IAAI,CAACR,IAAI,CAACE,OAAO,CAAC,EAAAG,EAAA,GAAAC,YAAA,CAAAG,MAAA,EAAAJ,EAAA,IAAE;QAAxC,IAAMK,GAAG,GAAAJ,YAAA,CAAAD,EAAA;QACb,IAAIK,GAAG,KAAK,SAAS,EAAE;UACtBV,IAAI,CAACW,SAAS,GAAGX,IAAI,CAACE,OAAO,WAAQ;QACtC,CAAC,MAAM;UACNF,IAAI,kBAAAY,MAAA,CAAkBF,GAAG,EAAG,GAAGV,IAAI,CAACE,OAAO,CAACQ,GAAG,CAAC;QACjD;MACD;IACD,CAAC,MAAM;MACNV,IAAI,CAACW,SAAS,GAAGX,IAAI,CAACE,OAAO;IAC9B;IACA,OAAOF,IAAI,CAACE,OAAO;EACpB;EACA,IAAIF,IAAI,CAACa,QAAQ,EAAE;IAClBb,IAAI,CAACc,IAAI,GAAGd,IAAI,CAACa,QAAQ;IACzB,OAAOb,IAAI,CAACa,QAAQ;EACrB;EACA,OAAOb,IAAI;AACZ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameLegacyProperties.test.js","names":["renameLegacyProperties","describe","it","formatAs","minTime","should","deep","equal","unit","threshold","week","threshold_for_week"],"sources":["../../source/steps/renameLegacyProperties.test.js"],"sourcesContent":["import renameLegacyProperties from './renameLegacyProperties.js'\r\n\r\ndescribe('steps/renameLegacyProperties', () => {\r\n\tit('should rename legacy properties', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: 1\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (minTime: undefined)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now'\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (`minTime` is an object)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: {\r\n\t\t\t\tweek: 2,\r\n\t\t\t\tdefault: 1\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1,\r\n\t\t\tthreshold_for_week: 2\r\n\t\t})\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"renameLegacyProperties.test.js","names":["renameLegacyProperties","describe","it","formatAs","minTime","should","deep","equal","unit","threshold","week","threshold_for_week"],"sources":["../../source/steps/renameLegacyProperties.test.js"],"sourcesContent":["import renameLegacyProperties from './renameLegacyProperties.js'\r\n\r\ndescribe('steps/renameLegacyProperties', () => {\r\n\tit('should rename legacy properties', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: 1\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (minTime: undefined)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now'\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now'\r\n\t\t})\r\n\t})\r\n\r\n\tit('should rename legacy properties (`minTime` is an object)', () => {\r\n\t\trenameLegacyProperties({\r\n\t\t\tformatAs: 'now',\r\n\t\t\tminTime: {\r\n\t\t\t\tweek: 2,\r\n\t\t\t\tdefault: 1\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tunit: 'now',\r\n\t\t\tthreshold: 1,\r\n\t\t\tthreshold_for_week: 2\r\n\t\t})\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,6BAA6B;AAEhEC,QAAQ,CAAC,8BAA8B,EAAE,YAAM;EAC9CC,EAAE,CAAC,iCAAiC,EAAE,YAAM;IAC3CF,sBAAsB,CAAC;MACtBG,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;IACV,CAAC,CAAC,CAACC,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE,KAAK;MACXC,SAAS,EAAE;IACZ,CAAC,CAAC;EACH,CAAC,CAAC;EAEFP,EAAE,CAAC,sDAAsD,EAAE,YAAM;IAChEF,sBAAsB,CAAC;MACtBG,QAAQ,EAAE;IACX,CAAC,CAAC,CAACE,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE;IACP,CAAC,CAAC;EACH,CAAC,CAAC;EAEFN,EAAE,CAAC,0DAA0D,EAAE,YAAM;IACpEF,sBAAsB,CAAC;MACtBG,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;QACRM,IAAI,EAAE,CAAC;QACP,WAAS;MACV;IACD,CAAC,CAAC,CAACL,MAAM,CAACC,IAAI,CAACC,KAAK,CAAC;MACpBC,IAAI,EAAE,KAAK;MACXC,SAAS,EAAE,CAAC;MACZE,kBAAkB,EAAE;IACrB,CAAC,CAAC;EACH,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","names":["formatAs"],"sources":["../../source/steps/round.js"],"sourcesContent":["// just now\r\n// 1 second ago\r\n// 2 seconds ago\r\n// …\r\n// 59 seconds ago\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// …\r\n// 59 minutes ago\r\n// 1 hour ago\r\n// 2 hours ago\r\n// …\r\n// 24 hours ago\r\n// 1 day ago\r\n// 2 days ago\r\n// …\r\n// 6 days ago\r\n// 1 week ago\r\n// 2 weeks ago\r\n// …\r\n// 3 weeks ago\r\n// 1 month ago\r\n// 2 months ago\r\n// …\r\n// 11 months ago\r\n// 1 year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\tformatAs: 'now'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'second'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'minute'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'hour'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'day'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'week'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'month'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'year'\r\n\t}\r\n]"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,CACd;EACCA,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"round.js","names":["formatAs"],"sources":["../../source/steps/round.js"],"sourcesContent":["// just now\r\n// 1 second ago\r\n// 2 seconds ago\r\n// …\r\n// 59 seconds ago\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// …\r\n// 59 minutes ago\r\n// 1 hour ago\r\n// 2 hours ago\r\n// …\r\n// 24 hours ago\r\n// 1 day ago\r\n// 2 days ago\r\n// …\r\n// 6 days ago\r\n// 1 week ago\r\n// 2 weeks ago\r\n// …\r\n// 3 weeks ago\r\n// 1 month ago\r\n// 2 months ago\r\n// …\r\n// 11 months ago\r\n// 1 year ago\r\n// 2 years ago\r\n// …\r\nexport default [\r\n\t{\r\n\t\tformatAs: 'now'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'second'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'minute'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'hour'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'day'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'week'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'month'\r\n\t},\r\n\t{\r\n\t\tformatAs: 'year'\r\n\t}\r\n]"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,CACd;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,EACD;EACCA,QAAQ,EAAE;AACX,CAAC,CACD","ignoreList":[]}
|
|
@@ -8,7 +8,6 @@ describe('steps/round', function () {
|
|
|
8
8
|
units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
expect(getStepFor(0).formatAs).to.equal('now');
|
|
13
12
|
expect(getStepFor(0.9).formatAs).to.equal('now');
|
|
14
13
|
expect(getStepFor(1).formatAs).to.equal('second');
|
|
@@ -26,7 +25,6 @@ describe('steps/round', function () {
|
|
|
26
25
|
units: ['now', 'second', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
|
27
26
|
});
|
|
28
27
|
};
|
|
29
|
-
|
|
30
28
|
expect(getStepFor(0).formatAs).to.equal('now');
|
|
31
29
|
expect(getStepFor(0.49).formatAs).to.equal('now');
|
|
32
30
|
expect(getStepFor(0.5).formatAs).to.equal('second');
|
|
@@ -45,7 +43,6 @@ describe('steps/round', function () {
|
|
|
45
43
|
units: ['now', 'second', 'minute', 'hour', 'day', 'month', 'year']
|
|
46
44
|
});
|
|
47
45
|
};
|
|
48
|
-
|
|
49
46
|
expect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day');
|
|
50
47
|
});
|
|
51
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.test.js","names":["getStep","steps","describe","it","getStepFor","secondsPassed","round","units","expect","formatAs","to","equal"],"sources":["../../source/steps/round.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './round.js'\r\n\r\ndescribe('steps/round', () => {\r\n\tit('should get step correctly (round: \"floor\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'floor',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.9).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.9).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60 - 1).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(24 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should get step correctly (round: \"round\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'round',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.49).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.5).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.4).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(59.4 * 60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.49 * 60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.5 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should use \"day\"s when \"week\"s are not allowed', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"round.test.js","names":["getStep","steps","describe","it","getStepFor","secondsPassed","round","units","expect","formatAs","to","equal"],"sources":["../../source/steps/round.test.js"],"sourcesContent":["import getStep from './getStep.js'\r\nimport steps from './round.js'\r\n\r\ndescribe('steps/round', () => {\r\n\tit('should get step correctly (round: \"floor\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'floor',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.9).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.9).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60 - 1).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(24 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should get step correctly (round: \"round\")', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tround: 'round',\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'week',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(0).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.49).formatAs).to.equal('now')\r\n\t\texpect(getStepFor(0.5).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(1).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(59.4).formatAs).to.equal('second')\r\n\t\texpect(getStepFor(60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(59.4 * 60).formatAs).to.equal('minute')\r\n\t\texpect(getStepFor(60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.49 * 60 * 60).formatAs).to.equal('hour')\r\n\t\texpect(getStepFor(23.5 * 60 * 60).formatAs).to.equal('day')\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('week')\r\n\t})\r\n\r\n\tit('should use \"day\"s when \"week\"s are not allowed', () => {\r\n\t\tconst getStepFor = (secondsPassed) => getStep(steps, secondsPassed, {\r\n\t\t\tunits: [\r\n\t\t\t\t'now',\r\n\t\t\t\t'second',\r\n\t\t\t\t'minute',\r\n\t\t\t\t'hour',\r\n\t\t\t\t'day',\r\n\t\t\t\t'month',\r\n\t\t\t\t'year'\r\n\t\t\t]\r\n\t\t})\r\n\r\n\t\texpect(getStepFor(7 * 24 * 60 * 60).formatAs).to.equal('day')\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,OAAO,MAAM,cAAc;AAClC,OAAOC,KAAK,MAAM,YAAY;AAE9BC,QAAQ,CAAC,aAAa,EAAE,YAAM;EAC7BC,EAAE,CAAC,4CAA4C,EAAE,YAAM;IACtD,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,aAAa;MAAA,OAAKL,OAAO,CAACC,KAAK,EAAEI,aAAa,EAAE;QACnEC,KAAK,EAAE,OAAO;QACdC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAACK,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAC9CH,MAAM,CAACJ,UAAU,CAAC,GAAG,CAAC,CAACK,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;IAChDH,MAAM,CAACJ,UAAU,CAAC,CAAC,CAAC,CAACK,QAAQ,CAAC,CAACC,EAAE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AUA,CAAIC,aAAa;MAAA,OAAKL,OAAO,CAACC,KAAK,EAAEI,aAAa,EAAE;QACnEE,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,MAAM;MAER,CAAC,CAAC;IAAA;IAEFC,MAAM,CAACJ,UAAU,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAACK,QAAQ,CAAC,CAACC,EAAE,CAACC,KAAK,CAAC,KAAK,CAAC;EAC9D,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
package/modules/steps/units.js
CHANGED
|
@@ -5,37 +5,33 @@ export var hour = 60 * minute; // in seconds
|
|
|
5
5
|
export var day = 24 * hour; // in seconds
|
|
6
6
|
|
|
7
7
|
export var week = 7 * day; // in seconds
|
|
8
|
-
// https://www.quora.com/What-is-the-average-number-of-days-in-a-month
|
|
9
8
|
|
|
9
|
+
// https://www.quora.com/What-is-the-average-number-of-days-in-a-month
|
|
10
10
|
export var month = 30.44 * day; // in seconds
|
|
11
|
-
// "400 years have 146097 days (taking into account leap year rules)"
|
|
12
11
|
|
|
12
|
+
// "400 years have 146097 days (taking into account leap year rules)"
|
|
13
13
|
export var year = 146097 / 400 * day; // in seconds
|
|
14
14
|
|
|
15
15
|
export function getSecondsInUnit(unit) {
|
|
16
16
|
switch (unit) {
|
|
17
17
|
case 'second':
|
|
18
18
|
return 1;
|
|
19
|
-
|
|
20
19
|
case 'minute':
|
|
21
20
|
return minute;
|
|
22
|
-
|
|
23
21
|
case 'hour':
|
|
24
22
|
return hour;
|
|
25
|
-
|
|
26
23
|
case 'day':
|
|
27
24
|
return day;
|
|
28
|
-
|
|
29
25
|
case 'week':
|
|
30
26
|
return week;
|
|
31
|
-
|
|
32
27
|
case 'month':
|
|
33
28
|
return month;
|
|
34
|
-
|
|
35
29
|
case 'year':
|
|
36
30
|
return year;
|
|
37
31
|
}
|
|
38
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// export function getPreviousUnitFor(unit) {
|
|
39
35
|
// switch (unit) {
|
|
40
36
|
// case 'second':
|
|
41
37
|
// return 'now'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","names":["minute","hour","day","week","month","year","getSecondsInUnit","unit"],"sources":["../../source/steps/units.js"],"sourcesContent":["export const minute = 60 // in seconds\r\n\r\nexport const hour = 60 * minute // in seconds\r\n\r\nexport const day = 24 * hour // in seconds\r\n\r\nexport const week = 7 * day // in seconds\r\n\r\n// https://www.quora.com/What-is-the-average-number-of-days-in-a-month\r\nexport const month = 30.44 * day // in seconds\r\n\r\n// \"400 years have 146097 days (taking into account leap year rules)\"\r\nexport const year = (146097 / 400) * day // in seconds\r\n\r\nexport function getSecondsInUnit(unit) {\r\n\tswitch (unit) {\r\n\t\tcase 'second':\r\n\t\t\treturn 1\r\n\t\tcase 'minute':\r\n\t\t\treturn minute\r\n\t\tcase 'hour':\r\n\t\t\treturn hour\r\n\t\tcase 'day':\r\n\t\t\treturn day\r\n\t\tcase 'week':\r\n\t\t\treturn week\r\n\t\tcase 'month':\r\n\t\t\treturn month\r\n\t\tcase 'year':\r\n\t\t\treturn year\r\n\t}\r\n}\r\n\r\n// export function getPreviousUnitFor(unit) {\r\n// \tswitch (unit) {\r\n// \t\tcase 'second':\r\n// \t\t\treturn 'now'\r\n// \t\tcase 'minute':\r\n// \t\t\treturn 'second'\r\n// \t\tcase 'hour':\r\n// \t\t\treturn 'minute'\r\n// \t\tcase 'day':\r\n// \t\t\treturn 'hour'\r\n// \t\tcase 'week':\r\n// \t\t\treturn 'day'\r\n// \t\tcase 'month':\r\n// \t\t\treturn 'week'\r\n// \t\tcase 'year':\r\n// \t\t\treturn 'month'\r\n// \t}\r\n// }"],"mappings":"AAAA,OAAO,IAAMA,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"units.js","names":["minute","hour","day","week","month","year","getSecondsInUnit","unit"],"sources":["../../source/steps/units.js"],"sourcesContent":["export const minute = 60 // in seconds\r\n\r\nexport const hour = 60 * minute // in seconds\r\n\r\nexport const day = 24 * hour // in seconds\r\n\r\nexport const week = 7 * day // in seconds\r\n\r\n// https://www.quora.com/What-is-the-average-number-of-days-in-a-month\r\nexport const month = 30.44 * day // in seconds\r\n\r\n// \"400 years have 146097 days (taking into account leap year rules)\"\r\nexport const year = (146097 / 400) * day // in seconds\r\n\r\nexport function getSecondsInUnit(unit) {\r\n\tswitch (unit) {\r\n\t\tcase 'second':\r\n\t\t\treturn 1\r\n\t\tcase 'minute':\r\n\t\t\treturn minute\r\n\t\tcase 'hour':\r\n\t\t\treturn hour\r\n\t\tcase 'day':\r\n\t\t\treturn day\r\n\t\tcase 'week':\r\n\t\t\treturn week\r\n\t\tcase 'month':\r\n\t\t\treturn month\r\n\t\tcase 'year':\r\n\t\t\treturn year\r\n\t}\r\n}\r\n\r\n// export function getPreviousUnitFor(unit) {\r\n// \tswitch (unit) {\r\n// \t\tcase 'second':\r\n// \t\t\treturn 'now'\r\n// \t\tcase 'minute':\r\n// \t\t\treturn 'second'\r\n// \t\tcase 'hour':\r\n// \t\t\treturn 'minute'\r\n// \t\tcase 'day':\r\n// \t\t\treturn 'hour'\r\n// \t\tcase 'week':\r\n// \t\t\treturn 'day'\r\n// \t\tcase 'month':\r\n// \t\t\treturn 'week'\r\n// \t\tcase 'year':\r\n// \t\t\treturn 'month'\r\n// \t}\r\n// }"],"mappings":"AAAA,OAAO,IAAMA,MAAM,GAAG,EAAE,EAAC;;AAEzB,OAAO,IAAMC,IAAI,GAAG,EAAE,GAAGD,MAAM,EAAC;;AAEhC,OAAO,IAAME,GAAG,GAAG,EAAE,GAAGD,IAAI,EAAC;;AAE7B,OAAO,IAAME,IAAI,GAAG,CAAC,GAAGD,GAAG,EAAC;;AAE5B;AACA,OAAO,IAAME,KAAK,GAAG,KAAK,GAAGF,GAAG,EAAC;;AAEjC;AACA,OAAO,IAAMG,IAAI,GAAI,MAAM,GAAG,GAAG,GAAIH,GAAG,EAAC;;AAEzC,OAAO,SAASI,gBAAgBA,CAACC,IAAI,EAAE;EACtC,QAAQA,IAAI;IACX,KAAK,QAAQ;MACZ,OAAO,CAAC;IACT,KAAK,QAAQ;MACZ,OAAOP,MAAM;IACd,KAAK,MAAM;MACV,OAAOC,IAAI;IACZ,KAAK,KAAK;MACT,OAAOC,GAAG;IACX,KAAK,MAAM;MACV,OAAOC,IAAI;IACZ,KAAK,OAAO;MACX,OAAOC,KAAK;IACb,KAAK,MAAM;MACV,OAAOC,IAAI;EACb;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import approximate from '../steps/approximate.js';
|
|
1
|
+
import approximate from '../steps/approximate.js';
|
|
2
|
+
|
|
3
|
+
// "gradation" is a legacy name for "steps".
|
|
2
4
|
// It's here just for legacy compatibility.
|
|
3
5
|
// Use "steps" name instead.
|
|
6
|
+
|
|
4
7
|
// "flavour" is a legacy name for "labels".
|
|
5
8
|
// It's here just for legacy compatibility.
|
|
6
9
|
// Use "labels" name instead.
|
|
10
|
+
|
|
7
11
|
// "units" is a legacy property.
|
|
8
12
|
// It's here just for legacy compatibility.
|
|
9
13
|
// Developers shouldn't need to use it in their custom styles.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approximate.js","names":["approximate","gradation","flavour","units"],"sources":["../../source/style/approximate.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"approximate.js","names":["approximate","gradation","flavour","units"],"sources":["../../source/style/approximate.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":"AAAA,OAAOA,WAAW,MAAM,yBAAyB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,eAAe;EACdC,SAAS,EAAED,WAAW;EACtBE,OAAO,EAAE,MAAM;EACfC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;AAER,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import approximate from '../steps/approximate.js';
|
|
1
|
+
import approximate from '../steps/approximate.js';
|
|
2
|
+
|
|
3
|
+
// "gradation" is a legacy name for "steps".
|
|
2
4
|
// It's here just for legacy compatibility.
|
|
3
5
|
// Use "steps" name instead.
|
|
6
|
+
|
|
4
7
|
// "flavour" is a legacy name for "labels".
|
|
5
8
|
// It's here just for legacy compatibility.
|
|
6
9
|
// Use "labels" name instead.
|
|
10
|
+
|
|
7
11
|
// "units" is a legacy property.
|
|
8
12
|
// It's here just for legacy compatibility.
|
|
9
13
|
// Developers shouldn't need to use it in their custom styles.
|
|
14
|
+
|
|
10
15
|
// Similar to the default style but with "ago" omitted.
|
|
11
16
|
//
|
|
12
17
|
// just now
|
|
@@ -30,7 +35,6 @@ import approximate from '../steps/approximate.js'; // "gradation" is a legacy na
|
|
|
30
35
|
// a year
|
|
31
36
|
// 2 years
|
|
32
37
|
//
|
|
33
|
-
|
|
34
38
|
export default {
|
|
35
39
|
gradation: approximate,
|
|
36
40
|
flavour: 'long-time',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approximateTime.js","names":["approximate","gradation","flavour","units"],"sources":["../../source/style/approximateTime.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\n// Similar to the default style but with \"ago\" omitted.\r\n//\r\n// just now\r\n// 5 minutes\r\n// 10 minutes\r\n// 15 minutes\r\n// 20 minutes\r\n// an hour\r\n// 2 hours\r\n// …\r\n// 20 hours\r\n// 1 day\r\n// 2 days\r\n// a week\r\n// 2 weeks\r\n// 3 weeks\r\n// a month\r\n// 2 months\r\n// 3 months\r\n// 4 months\r\n// a year\r\n// 2 years\r\n//\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long-time',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":"AAAA,OAAOA,
|
|
1
|
+
{"version":3,"file":"approximateTime.js","names":["approximate","gradation","flavour","units"],"sources":["../../source/style/approximateTime.js"],"sourcesContent":["import approximate from '../steps/approximate.js'\r\n\r\n// \"gradation\" is a legacy name for \"steps\".\r\n// It's here just for legacy compatibility.\r\n// Use \"steps\" name instead.\r\n\r\n// \"flavour\" is a legacy name for \"labels\".\r\n// It's here just for legacy compatibility.\r\n// Use \"labels\" name instead.\r\n\r\n// \"units\" is a legacy property.\r\n// It's here just for legacy compatibility.\r\n// Developers shouldn't need to use it in their custom styles.\r\n\r\n// Similar to the default style but with \"ago\" omitted.\r\n//\r\n// just now\r\n// 5 minutes\r\n// 10 minutes\r\n// 15 minutes\r\n// 20 minutes\r\n// an hour\r\n// 2 hours\r\n// …\r\n// 20 hours\r\n// 1 day\r\n// 2 days\r\n// a week\r\n// 2 weeks\r\n// 3 weeks\r\n// a month\r\n// 2 months\r\n// 3 months\r\n// 4 months\r\n// a year\r\n// 2 years\r\n//\r\nexport default {\r\n\tgradation: approximate,\r\n\tflavour: 'long-time',\r\n\tunits: [\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"mappings":"AAAA,OAAOA,WAAW,MAAM,yBAAyB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;EACdC,SAAS,EAAED,WAAW;EACtBE,OAAO,EAAE,WAAW;EACpBC,KAAK,EAAE,CACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM;AAER,CAAC","ignoreList":[]}
|