lemmy/ui/src/components/moment-time.tsx
2019-03-27 12:54:55 -07:00

29 lines
597 B
TypeScript

import { Component, linkEvent } from 'inferno';
import * as moment from 'moment';
interface MomentTimeProps {
data: {
published: string;
updated?: string;
}
}
export class MomentTime extends Component<MomentTimeProps, any> {
constructor(props, context) {
super(props, context);
}
render() {
if (this.props.data.updated) {
return (
<span className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span>
)
} else {
return (
<span>{moment.utc(this.props.data.published).fromNow()}</span>
)
}
}
}