Last active
July 10, 2019 14:37
-
-
Save jvorcak/e1e5e1d72d8b73576da583e8f372cee9 to your computer and use it in GitHub Desktop.
Humanize duration wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import humanizeDuration from "humanize-duration" | |
const shortEnglishHumanizer = humanizeDuration.humanizer({ | |
language: 'shortEn', | |
spacer: '', | |
delimiter: ' ', | |
languages: { | |
shortEn: { | |
y: function() { return 'y' }, | |
mo: function() { return 'mo' }, | |
w: function() { return 'w' }, | |
d: function() { return 'd' }, | |
h: function() { return 'h' }, | |
m: function() { return 'm' }, | |
s: function() { return 's' }, | |
ms: function() { return 'ms' }, | |
} | |
} | |
}) | |
export default ({value}) => typeof value !== "number" ? <span></span> : <span>{shortEnglishHumanizer(value*1000)}</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment