This repository has been archived on 2020-04-21. You can view files and clone it, but cannot push or open issues or pull requests.
lemmy/ui/src/components/moment-time.tsx
2019-04-08 20:28:07 -07:00

28 lines
662 B
TypeScript

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