]> Untitled Git - lemmy.git/blob - ui/src/components/moment-time.tsx
Merge branch 'moderation'
[lemmy.git] / ui / src / components / moment-time.tsx
1 import { Component } from 'inferno';
2 import * as moment from 'moment';
3
4 interface MomentTimeProps {
5   data: {
6     published?: string;
7     when_?: string;
8     updated?: string;
9   }
10 }
11
12 export class MomentTime extends Component<MomentTimeProps, any> {
13
14   constructor(props: any, context: any) {
15     super(props, context);
16   }
17
18   render() {
19     if (this.props.data.updated) {
20       return (
21         <span title={this.props.data.updated} className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span>
22       )
23     } else {
24       let str = this.props.data.published || this.props.data.when_;
25       return (
26         <span title={str}>{moment.utc(str).fromNow()}</span>
27       )
28     }
29   }
30 }