Created
May 18, 2014 04:11
-
-
Save GirlBossRush/1975a22fc47e7fdc9ab1 to your computer and use it in GitHub Desktop.
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
REFRESH_DELAY = 6000 | |
@HumanTime = React.createClass | |
displayName: "humantime" | |
getInitialState: -> | |
{relativeTime: @humanize(@props.datetime)} | |
componentDidMount: -> | |
@interval = setInterval(@refresh, REFRESH_DELAY) | |
componentWillUnmount: -> | |
clearInterval @interval | |
humanize: (datetime) -> | |
moment(datetime).fromNow() | |
refresh: -> | |
@setState relativeTime: @humanize(@props.datetime) | |
render: -> | |
R.time {className: "human-time", dateTime: @props.datetime}, | |
@state.relativeTime | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment