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,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _roundMinute = _interopRequireDefault(require("./roundMinute.js"));
|
|
4
|
-
|
|
5
4
|
var _TimeAgo = _interopRequireDefault(require("../TimeAgo.js"));
|
|
6
|
-
|
|
7
5
|
var _index = require("../steps/index.js");
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
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); }
|
|
17
13
|
describe('style/round-minute', function () {
|
|
18
14
|
it('should format relative time (English) (round: "floor")', function () {
|
|
19
15
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
20
16
|
var now = new Date(2016, 3, 10, 22, 59).getTime();
|
|
21
|
-
|
|
22
17
|
var formatInterval = function formatInterval(secondsPassed) {
|
|
23
18
|
return timeAgo.format(now - secondsPassed * 1000, _objectSpread(_objectSpread({
|
|
24
19
|
now: now
|
|
@@ -26,7 +21,6 @@ describe('style/round-minute', function () {
|
|
|
26
21
|
round: 'floor'
|
|
27
22
|
}));
|
|
28
23
|
};
|
|
29
|
-
|
|
30
24
|
formatInterval(0).should.equal('just now');
|
|
31
25
|
formatInterval(0.9).should.equal('just now');
|
|
32
26
|
formatInterval(1).should.equal('just now');
|
|
@@ -35,52 +29,51 @@ describe('style/round-minute', function () {
|
|
|
35
29
|
formatInterval(1.9 * 60).should.equal('1 minute ago');
|
|
36
30
|
formatInterval(2 * 60).should.equal('2 minutes ago');
|
|
37
31
|
formatInterval(2.9 * 60).should.equal('2 minutes ago');
|
|
38
|
-
formatInterval(3 * 60).should.equal('3 minutes ago');
|
|
39
|
-
|
|
32
|
+
formatInterval(3 * 60).should.equal('3 minutes ago');
|
|
33
|
+
// …
|
|
40
34
|
formatInterval(59.9 * 60).should.equal('59 minutes ago');
|
|
41
35
|
formatInterval(60 * 60).should.equal('1 hour ago');
|
|
42
36
|
formatInterval(1.9 * 60 * 60).should.equal('1 hour ago');
|
|
43
37
|
formatInterval(2 * 60 * 60).should.equal('2 hours ago');
|
|
44
38
|
formatInterval(2.9 * 60 * 60).should.equal('2 hours ago');
|
|
45
|
-
formatInterval(3 * 60 * 60).should.equal('3 hours ago');
|
|
46
|
-
|
|
39
|
+
formatInterval(3 * 60 * 60).should.equal('3 hours ago');
|
|
40
|
+
// …
|
|
47
41
|
formatInterval(23.9 * 60 * 60).should.equal('23 hours ago');
|
|
48
42
|
formatInterval(24 * 60 * 60).should.equal('1 day ago');
|
|
49
43
|
formatInterval(1.9 * _index.day).should.equal('1 day ago');
|
|
50
44
|
formatInterval(2 * _index.day).should.equal('2 days ago');
|
|
51
45
|
formatInterval(2.9 * _index.day).should.equal('2 days ago');
|
|
52
|
-
formatInterval(3 * _index.day).should.equal('3 days ago');
|
|
53
|
-
|
|
46
|
+
formatInterval(3 * _index.day).should.equal('3 days ago');
|
|
47
|
+
// …
|
|
54
48
|
formatInterval(6.9 * _index.day).should.equal('6 days ago');
|
|
55
|
-
formatInterval(7 * _index.day).should.equal('1 week ago');
|
|
56
|
-
|
|
49
|
+
formatInterval(7 * _index.day).should.equal('1 week ago');
|
|
50
|
+
// …
|
|
57
51
|
formatInterval(3.9 * 7 * _index.day).should.equal('3 weeks ago');
|
|
58
52
|
formatInterval(4 * 7 * _index.day).should.equal('4 weeks ago');
|
|
59
53
|
formatInterval(30.51 * _index.day).should.equal('1 month ago');
|
|
60
54
|
formatInterval(1.9 * _index.month).should.equal('1 month ago');
|
|
61
55
|
formatInterval(2 * _index.month).should.equal('2 months ago');
|
|
62
56
|
formatInterval(2.9 * _index.month).should.equal('2 months ago');
|
|
63
|
-
formatInterval(3 * _index.month).should.equal('3 months ago');
|
|
64
|
-
|
|
57
|
+
formatInterval(3 * _index.month).should.equal('3 months ago');
|
|
58
|
+
// …
|
|
65
59
|
formatInterval(11.9 * _index.month).should.equal('11 months ago');
|
|
66
60
|
formatInterval(12 * _index.month).should.equal('1 year ago');
|
|
67
61
|
formatInterval(1.99 * _index.year).should.equal('1 year ago');
|
|
68
|
-
formatInterval(2 * _index.year).should.equal('2 years ago');
|
|
69
|
-
//
|
|
62
|
+
formatInterval(2 * _index.year).should.equal('2 years ago');
|
|
63
|
+
// …
|
|
70
64
|
|
|
65
|
+
// Test future dates.
|
|
71
66
|
formatInterval(-1 * 3 * 60).should.equal('in 3 minutes');
|
|
72
67
|
formatInterval(-1 * _index.month * 8).should.equal('in 8 months');
|
|
73
68
|
});
|
|
74
69
|
it('should format relative time (English)', function () {
|
|
75
70
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
76
71
|
var now = new Date(2016, 3, 10, 22, 59).getTime();
|
|
77
|
-
|
|
78
72
|
var formatInterval = function formatInterval(secondsPassed) {
|
|
79
73
|
return timeAgo.format(now - secondsPassed * 1000, _objectSpread({
|
|
80
74
|
now: now
|
|
81
75
|
}, _roundMinute["default"]));
|
|
82
76
|
};
|
|
83
|
-
|
|
84
77
|
formatInterval(0).should.equal('just now');
|
|
85
78
|
formatInterval(0.49).should.equal('just now');
|
|
86
79
|
formatInterval(0.5).should.equal('just now');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundMinute.test.js","names":["describe","it","timeAgo","TimeAgo","now","Date","getTime","formatInterval","secondsPassed","format","roundMinute","round","should","equal","day","month","year"],"sources":["../../source/style/roundMinute.test.js"],"sourcesContent":["import roundMinute from './roundMinute.js'\r\nimport TimeAgo from '../TimeAgo.js'\r\nimport { day, month, year } from '../steps/index.js'\r\n\r\ndescribe('style/round-minute', () => {\r\n\tit('should format relative time (English) (round: \"floor\")', () => {\r\n\t\tconst timeAgo = new TimeAgo('en')\r\n\r\n\t\tconst now = new Date(2016, 3, 10, 22, 59).getTime()\r\n\t\tconst formatInterval = (secondsPassed) => timeAgo.format(now - secondsPassed * 1000, { now, ...roundMinute, round: 'floor' })\r\n\r\n\t\tformatInterval(0).should.equal('just now')\r\n\t\tformatInterval(0.9).should.equal('just now')\r\n\t\tformatInterval(1).should.equal('just now')\r\n\t\tformatInterval(59.9).should.equal('just now')\r\n\t\tformatInterval(60).should.equal('1 minute ago')\r\n\t\tformatInterval(1.9 * 60).should.equal('1 minute ago')\r\n\t\tformatInterval(2 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.9 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(3 * 60).should.equal('3 minutes ago')\r\n\t\t// …\r\n\t\tformatInterval(59.9 * 60).should.equal('59 minutes ago')\r\n\t\tformatInterval(60 * 60).should.equal('1 hour ago')\r\n\t\tformatInterval(1.9 * 60 * 60).should.equal('1 hour ago')\r\n\t\tformatInterval(2 * 60 * 60).should.equal('2 hours ago')\r\n\t\tformatInterval(2.9 * 60 * 60).should.equal('2 hours ago')\r\n\t\tformatInterval(3 * 60 * 60).should.equal('3 hours ago')\r\n\t\t// …\r\n\t\tformatInterval(23.9 * 60 * 60).should.equal('23 hours ago')\r\n\t\tformatInterval(24 * 60 * 60).should.equal('1 day ago')\r\n\t\tformatInterval(1.9 * day).should.equal('1 day ago')\r\n\t\tformatInterval(2 * day).should.equal('2 days ago')\r\n\t\tformatInterval(2.9 * day).should.equal('2 days ago')\r\n\t\tformatInterval(3 * day).should.equal('3 days ago')\r\n\t\t// …\r\n\t\tformatInterval(6.9 * day).should.equal('6 days ago')\r\n\t\tformatInterval(7 * day).should.equal('1 week ago')\r\n\t\t// …\r\n\t\tformatInterval(3.9 * 7 * day).should.equal('3 weeks ago')\r\n\t\tformatInterval(4 * 7 * day).should.equal('4 weeks ago')\r\n\t\tformatInterval(30.51 * day).should.equal('1 month ago')\r\n\t\tformatInterval(1.9 * month).should.equal('1 month ago')\r\n\t\tformatInterval(2 * month).should.equal('2 months ago')\r\n\t\tformatInterval(2.9 * month).should.equal('2 months ago')\r\n\t\tformatInterval(3 * month).should.equal('3 months ago')\r\n\t\t// …\r\n\t\tformatInterval(11.9 * month).should.equal('11 months ago')\r\n\t\tformatInterval(12 * month).should.equal('1 year ago')\r\n\t\tformatInterval(1.99 * year).should.equal('1 year ago')\r\n\t\tformatInterval(2 * year).should.equal('2 years ago')\r\n\t\t// …\r\n\r\n\t\t// Test future dates.\r\n\t\tformatInterval(-1 * 3 * 60).should.equal('in 3 minutes')\r\n\t\tformatInterval(-1 * month * 8).should.equal('in 8 months')\r\n\t})\r\n\r\n\tit('should format relative time (English)', () => {\r\n\t\tconst timeAgo = new TimeAgo('en')\r\n\r\n\t\tconst now = new Date(2016, 3, 10, 22, 59).getTime()\r\n\t\tconst formatInterval = (secondsPassed) => timeAgo.format(now - secondsPassed * 1000, { now, ...roundMinute })\r\n\r\n\t\tformatInterval(0).should.equal('just now')\r\n\t\tformatInterval(0.49).should.equal('just now')\r\n\t\tformatInterval(0.5).should.equal('just now')\r\n\t\tformatInterval(29.9).should.equal('just now')\r\n\t\tformatInterval(30).should.equal('1 minute ago')\r\n\t\tformatInterval(1.49 * 60).should.equal('1 minute ago')\r\n\t\tformatInterval(1.5 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.49 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.5 * 60).should.equal('3 minutes ago')\r\n\t})\r\n})"],"mappings":";;AAAA;;AACA;;AACA;;;;;;;;;;AAEAA,QAAQ,CAAC,oBAAD,EAAuB,YAAM;EACpCC,EAAE,CAAC,wDAAD,EAA2D,YAAM;IAClE,IAAMC,OAAO,GAAG,IAAIC,mBAAJ,CAAY,IAAZ,CAAhB;IAEA,IAAMC,GAAG,GAAG,IAAIC,IAAJ,CAAS,IAAT,EAAe,CAAf,EAAkB,EAAlB,EAAsB,EAAtB,EAA0B,EAA1B,EAA8BC,OAA9B,EAAZ;;IACA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACC,aAAD;MAAA,OAAmBN,OAAO,CAACO,MAAR,CAAeL,GAAG,GAAGI,aAAa,GAAG,IAArC;QAA6CJ,GAAG,EAAHA;MAA7C,GAAqDM,uBAArD;QAAkEC,KAAK,EAAE;MAAzE,GAAnB;IAAA,CAAvB;;IAEAJ,cAAc,CAAC,CAAD,CAAd,CAAkBK,MAAlB,CAAyBC,KAAzB,CAA+B,UAA/B;IACAN,cAAc,CAAC,GAAD,CAAd,CAAoBK,MAApB,CAA2BC,KAA3B,CAAiC,UAAjC;IACAN,cAAc,CAAC,CAAD,CAAd,CAAkBK,MAAlB,CAAyBC,KAAzB,CAA+B,UAA/B;IACAN,cAAc,CAAC,IAAD,CAAd,CAAqBK,MAArB,CAA4BC,KAA5B,CAAkC,UAAlC;IACAN,cAAc,CAAC,EAAD,CAAd,CAAmBK,MAAnB,CAA0BC,KAA1B,CAAgC,cAAhC;IACAN,cAAc,CAAC,MAAM,EAAP,CAAd,CAAyBK,MAAzB,CAAgCC,KAAhC,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zB,CAAgCC,KAAhC,CAAsC,eAAtC;IACAN,cAAc,CAAC,OAAO,EAAR,CAAd,CAA0BK,MAA1B,CAAiCC,KAAjC,CAAuC,eAAvC;IACAN,cAAc,CAAC,MAAM,EAAP,CAAd,CAAyBK,MAAzB,CAAgCC,KAAhC,CAAsC,eAAtC;EACA,CAfC,CAAF;AAgBA,CArEO,CAAR"}
|
|
1
|
+
{"version":3,"file":"roundMinute.test.js","names":["_roundMinute","_interopRequireDefault","require","_TimeAgo","_index","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","ownKeys","r","t","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","toPrimitive","call","TypeError","String","Number","describe","it","timeAgo","TimeAgo","now","Date","getTime","formatInterval","secondsPassed","format","roundMinute","round","should","equal","day","month","year"],"sources":["../../source/style/roundMinute.test.js"],"sourcesContent":["import roundMinute from './roundMinute.js'\r\nimport TimeAgo from '../TimeAgo.js'\r\nimport { day, month, year } from '../steps/index.js'\r\n\r\ndescribe('style/round-minute', () => {\r\n\tit('should format relative time (English) (round: \"floor\")', () => {\r\n\t\tconst timeAgo = new TimeAgo('en')\r\n\r\n\t\tconst now = new Date(2016, 3, 10, 22, 59).getTime()\r\n\t\tconst formatInterval = (secondsPassed) => timeAgo.format(now - secondsPassed * 1000, { now, ...roundMinute, round: 'floor' })\r\n\r\n\t\tformatInterval(0).should.equal('just now')\r\n\t\tformatInterval(0.9).should.equal('just now')\r\n\t\tformatInterval(1).should.equal('just now')\r\n\t\tformatInterval(59.9).should.equal('just now')\r\n\t\tformatInterval(60).should.equal('1 minute ago')\r\n\t\tformatInterval(1.9 * 60).should.equal('1 minute ago')\r\n\t\tformatInterval(2 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.9 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(3 * 60).should.equal('3 minutes ago')\r\n\t\t// …\r\n\t\tformatInterval(59.9 * 60).should.equal('59 minutes ago')\r\n\t\tformatInterval(60 * 60).should.equal('1 hour ago')\r\n\t\tformatInterval(1.9 * 60 * 60).should.equal('1 hour ago')\r\n\t\tformatInterval(2 * 60 * 60).should.equal('2 hours ago')\r\n\t\tformatInterval(2.9 * 60 * 60).should.equal('2 hours ago')\r\n\t\tformatInterval(3 * 60 * 60).should.equal('3 hours ago')\r\n\t\t// …\r\n\t\tformatInterval(23.9 * 60 * 60).should.equal('23 hours ago')\r\n\t\tformatInterval(24 * 60 * 60).should.equal('1 day ago')\r\n\t\tformatInterval(1.9 * day).should.equal('1 day ago')\r\n\t\tformatInterval(2 * day).should.equal('2 days ago')\r\n\t\tformatInterval(2.9 * day).should.equal('2 days ago')\r\n\t\tformatInterval(3 * day).should.equal('3 days ago')\r\n\t\t// …\r\n\t\tformatInterval(6.9 * day).should.equal('6 days ago')\r\n\t\tformatInterval(7 * day).should.equal('1 week ago')\r\n\t\t// …\r\n\t\tformatInterval(3.9 * 7 * day).should.equal('3 weeks ago')\r\n\t\tformatInterval(4 * 7 * day).should.equal('4 weeks ago')\r\n\t\tformatInterval(30.51 * day).should.equal('1 month ago')\r\n\t\tformatInterval(1.9 * month).should.equal('1 month ago')\r\n\t\tformatInterval(2 * month).should.equal('2 months ago')\r\n\t\tformatInterval(2.9 * month).should.equal('2 months ago')\r\n\t\tformatInterval(3 * month).should.equal('3 months ago')\r\n\t\t// …\r\n\t\tformatInterval(11.9 * month).should.equal('11 months ago')\r\n\t\tformatInterval(12 * month).should.equal('1 year ago')\r\n\t\tformatInterval(1.99 * year).should.equal('1 year ago')\r\n\t\tformatInterval(2 * year).should.equal('2 years ago')\r\n\t\t// …\r\n\r\n\t\t// Test future dates.\r\n\t\tformatInterval(-1 * 3 * 60).should.equal('in 3 minutes')\r\n\t\tformatInterval(-1 * month * 8).should.equal('in 8 months')\r\n\t})\r\n\r\n\tit('should format relative time (English)', () => {\r\n\t\tconst timeAgo = new TimeAgo('en')\r\n\r\n\t\tconst now = new Date(2016, 3, 10, 22, 59).getTime()\r\n\t\tconst formatInterval = (secondsPassed) => timeAgo.format(now - secondsPassed * 1000, { now, ...roundMinute })\r\n\r\n\t\tformatInterval(0).should.equal('just now')\r\n\t\tformatInterval(0.49).should.equal('just now')\r\n\t\tformatInterval(0.5).should.equal('just now')\r\n\t\tformatInterval(29.9).should.equal('just now')\r\n\t\tformatInterval(30).should.equal('1 minute ago')\r\n\t\tformatInterval(1.49 * 60).should.equal('1 minute ago')\r\n\t\tformatInterval(1.5 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.49 * 60).should.equal('2 minutes ago')\r\n\t\tformatInterval(2.5 * 60).should.equal('3 minutes ago')\r\n\t})\r\n})"],"mappings":";;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAAoD,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAAA,SAAAK,QAAAR,CAAA,EAAAS,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAW,MAAA,CAAAE,qBAAA,QAAAV,CAAA,GAAAQ,MAAA,CAAAE,qBAAA,CAAAb,CAAA,GAAAS,CAAA,KAAAN,CAAA,GAAAA,CAAA,CAAAW,MA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AAC,cAAc,CAAC;IACtDN,cAAc,CAAC,GAAG,GAAG,EAAE,CAAC,CAACK,MAAM,CAACC,KAAK,CAAC,eAAe,CAAC;IACtDN,cAAc,CAAC,IAAI,GAAG,EAAE,CAAC,CAACK,MAAM,CAACC,KAAK,CAAC,eAAe,CAAC;IACvDN,cAAc,CAAC,GAAG,GAAG,EAAE,CAAC,CAACK,MAAM,CAACC,KAAK,CAAC,eAAe,CAAC;EACvD,CAAC,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -4,36 +4,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _index = require("../steps/index.js");
|
|
9
|
-
|
|
10
8
|
var _locale = require("../locale.js");
|
|
9
|
+
// // For compatibility with the old versions of this library.
|
|
10
|
+
// import renameLegacyProperties from './renameLegacyProperties.js'
|
|
11
11
|
|
|
12
|
-
var _renameLegacyProperties = _interopRequireDefault(require("./renameLegacyProperties.js"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
// For compatibility with the old versions of this library.
|
|
17
12
|
// Twitter-style relative date/time formatting.
|
|
18
13
|
// ("1m", "2h", "Mar 3", "Apr 4, 2012").
|
|
19
14
|
//
|
|
20
15
|
// Seconds, minutes or hours are shown for shorter intervals,
|
|
21
16
|
// and longer intervals are formatted using full date format.
|
|
17
|
+
|
|
22
18
|
var steps = [{
|
|
23
19
|
formatAs: 'second'
|
|
24
20
|
}, {
|
|
25
21
|
formatAs: 'minute'
|
|
26
22
|
}, {
|
|
27
23
|
formatAs: 'hour'
|
|
28
|
-
}];
|
|
29
|
-
// for various locales (is a global variable).
|
|
24
|
+
}];
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
// A cache for `Intl.DateTimeFormat` formatters
|
|
27
|
+
// for various locales (is a global variable).
|
|
28
|
+
var formatters = {};
|
|
32
29
|
|
|
30
|
+
// Starting from day intervals, output month and day.
|
|
33
31
|
var monthAndDay = {
|
|
34
32
|
minTime: function minTime(timestamp, _ref) {
|
|
35
33
|
var future = _ref.future,
|
|
36
|
-
|
|
34
|
+
getMinTimeForUnit = _ref.getMinTimeForUnit;
|
|
37
35
|
// Returns `23.5 * 60 * 60` when `round` is "round",
|
|
38
36
|
// and `24 * 60 * 60` when `round` is "floor".
|
|
39
37
|
return getMinTimeForUnit('day');
|
|
@@ -44,27 +42,24 @@ var monthAndDay = {
|
|
|
44
42
|
formatters[locale] = {};
|
|
45
43
|
}
|
|
46
44
|
/* istanbul ignore else */
|
|
47
|
-
|
|
48
|
-
|
|
49
45
|
if (!formatters[locale].dayMonth) {
|
|
50
46
|
// "Apr 11" (MMMd)
|
|
51
47
|
formatters[locale].dayMonth = new Intl.DateTimeFormat(locale, {
|
|
52
48
|
month: 'short',
|
|
53
49
|
day: 'numeric'
|
|
54
50
|
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
}
|
|
52
|
+
// Output month and day.
|
|
58
53
|
return formatters[locale].dayMonth.format((0, _index.getDate)(value));
|
|
59
54
|
}
|
|
60
|
-
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// If the `date` happened/happens outside of current year,
|
|
61
58
|
// then output day, month and year.
|
|
62
59
|
// The interval should be such that the `date` lies outside of the current year.
|
|
63
|
-
|
|
64
60
|
var yearMonthAndDay = {
|
|
65
61
|
minTime: function minTime(timestamp, _ref2) {
|
|
66
62
|
var future = _ref2.future;
|
|
67
|
-
|
|
68
63
|
if (future) {
|
|
69
64
|
// January 1, 00:00, of the `date`'s year is right after
|
|
70
65
|
// the maximum `now` for formatting a future date:
|
|
@@ -73,8 +68,8 @@ var yearMonthAndDay = {
|
|
|
73
68
|
// After that, it's hours, minutes, seconds, and after that it's no longer `future`.
|
|
74
69
|
// The date is right after the maximum `now` for formatting a future date,
|
|
75
70
|
// so subtract 1 millisecond from it.
|
|
76
|
-
var maxFittingNow = new Date(new Date(timestamp).getFullYear(), 0).getTime() - 1;
|
|
77
|
-
|
|
71
|
+
var maxFittingNow = new Date(new Date(timestamp).getFullYear(), 0).getTime() - 1;
|
|
72
|
+
// Return `minTime` (in seconds).
|
|
78
73
|
return (timestamp - maxFittingNow) / 1000;
|
|
79
74
|
} else {
|
|
80
75
|
// January 1, 00:00, of the year following the `date`'s year
|
|
@@ -82,8 +77,8 @@ var yearMonthAndDay = {
|
|
|
82
77
|
// When `now` is before that date, the `date` is formatted as "day/month" (another step),
|
|
83
78
|
// When `now` is equal to or after that date, the `date` is formatted as "day/month/year" (this step).
|
|
84
79
|
// After that, it's hours, minutes, seconds, and after that it's no longer `future`.
|
|
85
|
-
var minFittingNow = new Date(new Date(timestamp).getFullYear() + 1, 0).getTime();
|
|
86
|
-
|
|
80
|
+
var minFittingNow = new Date(new Date(timestamp).getFullYear() + 1, 0).getTime();
|
|
81
|
+
// Return `minTime` (in seconds).
|
|
87
82
|
return (minFittingNow - timestamp) / 1000;
|
|
88
83
|
}
|
|
89
84
|
},
|
|
@@ -93,8 +88,6 @@ var yearMonthAndDay = {
|
|
|
93
88
|
formatters[locale] = {};
|
|
94
89
|
}
|
|
95
90
|
/* istanbul ignore else */
|
|
96
|
-
|
|
97
|
-
|
|
98
91
|
if (!formatters[locale].dayMonthYear) {
|
|
99
92
|
// "Apr 11, 2017" (yMMMd)
|
|
100
93
|
formatters[locale].dayMonthYear = new Intl.DateTimeFormat(locale, {
|
|
@@ -102,19 +95,19 @@ var yearMonthAndDay = {
|
|
|
102
95
|
month: 'short',
|
|
103
96
|
day: 'numeric'
|
|
104
97
|
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
98
|
+
}
|
|
99
|
+
// Output day, month and year.
|
|
108
100
|
return formatters[locale].dayMonthYear.format((0, _index.getDate)(value));
|
|
109
101
|
}
|
|
110
|
-
};
|
|
111
|
-
// then longer time intervals will be formatted as dates.
|
|
102
|
+
};
|
|
112
103
|
|
|
104
|
+
// If `Intl.DateTimeFormat` is supported,
|
|
105
|
+
// then longer time intervals will be formatted as dates.
|
|
113
106
|
/* istanbul ignore else */
|
|
114
|
-
|
|
115
107
|
if ((0, _locale.intlDateTimeFormatSupported)()) {
|
|
116
108
|
steps.push(monthAndDay, yearMonthAndDay);
|
|
117
|
-
}
|
|
109
|
+
}
|
|
110
|
+
// Otherwise, if `Intl.DateTimeFormat` is not supported,
|
|
118
111
|
// which could be the case when using Internet Explorer,
|
|
119
112
|
// then simply mimick "round" steps.
|
|
120
113
|
else {
|
|
@@ -128,20 +121,22 @@ else {
|
|
|
128
121
|
formatAs: 'year'
|
|
129
122
|
});
|
|
130
123
|
}
|
|
131
|
-
|
|
132
|
-
var _default = {
|
|
124
|
+
var _default = exports["default"] = {
|
|
133
125
|
steps: steps,
|
|
134
|
-
labels: [
|
|
135
|
-
|
|
136
|
-
'
|
|
126
|
+
labels: [
|
|
127
|
+
// "mini" labels are only defined for a few languages.
|
|
128
|
+
'mini',
|
|
129
|
+
// "short-time" labels are only defined for a few languages.
|
|
130
|
+
'short-time',
|
|
131
|
+
// "narrow" and "short" labels are defined for all languages.
|
|
137
132
|
// "narrow" labels can sometimes be weird (like "+5d."),
|
|
138
133
|
// but "short" labels have the " ago" part, so "narrow" seem
|
|
139
134
|
// more appropriate.
|
|
140
135
|
// "short" labels would have been more appropriate if they
|
|
141
136
|
// didn't have the " ago" part, hence the "short-time" above.
|
|
142
|
-
'narrow',
|
|
137
|
+
'narrow',
|
|
138
|
+
// Since "narrow" labels are always present, "short" element
|
|
143
139
|
// of this array can be removed.
|
|
144
140
|
'short']
|
|
145
141
|
};
|
|
146
|
-
exports["default"] = _default;
|
|
147
142
|
//# sourceMappingURL=twitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"twitter.js","names":["steps","formatAs","formatters","monthAndDay","minTime","timestamp","future","getMinTimeForUnit","format","value","locale","dayMonth","Intl","DateTimeFormat","month","day","getDate","yearMonthAndDay","maxFittingNow","Date","getFullYear","getTime","minFittingNow","dayMonthYear","year","intlDateTimeFormatSupported","push","labels"],"sources":["../../source/style/twitter.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"twitter.js","names":["_index","require","_locale","steps","formatAs","formatters","monthAndDay","minTime","timestamp","_ref","future","getMinTimeForUnit","format","value","locale","dayMonth","Intl","DateTimeFormat","month","day","getDate","yearMonthAndDay","_ref2","maxFittingNow","Date","getFullYear","getTime","minFittingNow","dayMonthYear","year","intlDateTimeFormatSupported","push","_default","exports","labels"],"sources":["../../source/style/twitter.js"],"sourcesContent":["import { getDate } from '../steps/index.js'\r\nimport { intlDateTimeFormatSupported } from '../locale.js'\r\n\r\n// // For compatibility with the old versions of this library.\r\n// import renameLegacyProperties from './renameLegacyProperties.js'\r\n\r\n// Twitter-style relative date/time formatting.\r\n// (\"1m\", \"2h\", \"Mar 3\", \"Apr 4, 2012\").\r\n//\r\n// Seconds, minutes or hours are shown for shorter intervals,\r\n// and longer intervals are formatted using full date format.\r\n\r\nconst steps = [\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]\r\n\r\n// A cache for `Intl.DateTimeFormat` formatters\r\n// for various locales (is a global variable).\r\nconst formatters = {}\r\n\r\n// Starting from day intervals, output month and day.\r\nconst monthAndDay = {\r\n\tminTime(timestamp, { future, getMinTimeForUnit }) {\r\n\t\t// Returns `23.5 * 60 * 60` when `round` is \"round\",\r\n\t\t// and `24 * 60 * 60` when `round` is \"floor\".\r\n\t\treturn getMinTimeForUnit('day')\r\n\t},\r\n\tformat(value, locale) {\r\n\t\t/* istanbul ignore else */\r\n\t\tif (!formatters[locale]) {\r\n\t\t\tformatters[locale] = {}\r\n\t\t}\r\n\t\t/* istanbul ignore else */\r\n\t\tif (!formatters[locale].dayMonth) {\r\n\t\t\t// \"Apr 11\" (MMMd)\r\n\t\t\tformatters[locale].dayMonth = new Intl.DateTimeFormat(locale, {\r\n\t\t\t\tmonth: 'short',\r\n\t\t\t\tday: 'numeric'\r\n\t\t\t})\r\n\t\t}\r\n\t\t// Output month and day.\r\n\t\treturn formatters[locale].dayMonth.format(getDate(value))\r\n\t}\r\n}\r\n\r\n// If the `date` happened/happens outside of current year,\r\n// then output day, month and year.\r\n// The interval should be such that the `date` lies outside of the current year.\r\nconst yearMonthAndDay = {\r\n\tminTime(timestamp, { future }) {\r\n\t\tif (future) {\r\n\t\t\t// January 1, 00:00, of the `date`'s year is right after\r\n\t\t\t// the maximum `now` for formatting a future date:\r\n\t\t\t// When `now` is before that date, the `date` is formatted as \"day/month/year\" (this step),\r\n\t\t\t// When `now` is equal to or after that date, the `date` is formatted as \"day/month\" (another step).\r\n\t\t\t// After that, it's hours, minutes, seconds, and after that it's no longer `future`.\r\n\t\t\t// The date is right after the maximum `now` for formatting a future date,\r\n\t\t\t// so subtract 1 millisecond from it.\r\n\t\t\tconst maxFittingNow = new Date(new Date(timestamp).getFullYear(), 0).getTime() - 1\r\n\t\t\t// Return `minTime` (in seconds).\r\n\t\t\treturn (timestamp - maxFittingNow) / 1000\r\n\t\t} else {\r\n\t\t\t// January 1, 00:00, of the year following the `date`'s year\r\n\t\t\t// is the minimum `now` for formatting a past date:\r\n\t\t\t// When `now` is before that date, the `date` is formatted as \"day/month\" (another step),\r\n\t\t\t// When `now` is equal to or after that date, the `date` is formatted as \"day/month/year\" (this step).\r\n\t\t\t// After that, it's hours, minutes, seconds, and after that it's no longer `future`.\r\n\t\t\tconst minFittingNow = new Date(new Date(timestamp).getFullYear() + 1, 0).getTime()\r\n\t\t\t// Return `minTime` (in seconds).\r\n\t\t\treturn (minFittingNow - timestamp) / 1000\r\n\t\t}\r\n\t},\r\n\tformat(value, locale) {\r\n\t\t/* istanbul ignore if */\r\n\t\tif (!formatters[locale]) {\r\n\t\t\tformatters[locale] = {}\r\n\t\t}\r\n\t\t/* istanbul ignore else */\r\n\t\tif (!formatters[locale].dayMonthYear) {\r\n\t\t\t// \"Apr 11, 2017\" (yMMMd)\r\n\t\t\tformatters[locale].dayMonthYear = new Intl.DateTimeFormat(locale, {\r\n\t\t\t\tyear: 'numeric',\r\n\t\t\t\tmonth: 'short',\r\n\t\t\t\tday: 'numeric'\r\n\t\t\t})\r\n\t\t}\r\n\t\t// Output day, month and year.\r\n\t\treturn formatters[locale].dayMonthYear.format(getDate(value))\r\n\t}\r\n}\r\n\r\n// If `Intl.DateTimeFormat` is supported,\r\n// then longer time intervals will be formatted as dates.\r\n/* istanbul ignore else */\r\nif (intlDateTimeFormatSupported()) {\r\n\tsteps.push(monthAndDay, yearMonthAndDay)\r\n}\r\n// Otherwise, if `Intl.DateTimeFormat` is not supported,\r\n// which could be the case when using Internet Explorer,\r\n// then simply mimick \"round\" steps.\r\nelse {\r\n\tsteps.push(\r\n\t\t{\r\n\t\t\tformatAs: 'day'\r\n\t\t},\r\n\t\t{\r\n\t\t\tformatAs: 'week'\r\n\t\t},\r\n\t\t{\r\n\t\t\tformatAs: 'month'\r\n\t\t},\r\n\t\t{\r\n\t\t\tformatAs: 'year'\r\n\t\t}\r\n\t)\r\n}\r\n\r\nexport default {\r\n\tsteps,\r\n\tlabels: [\r\n\t\t// \"mini\" labels are only defined for a few languages.\r\n\t\t'mini',\r\n\t\t// \"short-time\" labels are only defined for a few languages.\r\n\t\t'short-time',\r\n\t\t// \"narrow\" and \"short\" labels are defined for all languages.\r\n\t\t// \"narrow\" labels can sometimes be weird (like \"+5d.\"),\r\n\t\t// but \"short\" labels have the \" ago\" part, so \"narrow\" seem\r\n\t\t// more appropriate.\r\n\t\t// \"short\" labels would have been more appropriate if they\r\n\t\t// didn't have the \" ago\" part, hence the \"short-time\" above.\r\n\t\t'narrow',\r\n\t\t// Since \"narrow\" labels are always present, \"short\" element\r\n\t\t// of this array can be removed.\r\n\t\t'short'\r\n\t]\r\n}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