Skip to content

Instantly share code, notes, and snippets.

@jvorcak
Last active July 10, 2019 14:37
Show Gist options
  • Save jvorcak/e1e5e1d72d8b73576da583e8f372cee9 to your computer and use it in GitHub Desktop.
Save jvorcak/e1e5e1d72d8b73576da583e8f372cee9 to your computer and use it in GitHub Desktop.
Humanize duration wrapper
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