summaryrefslogtreecommitdiffstats
path: root/ui/src/components/moment-time.tsx
blob: f07f04a3f02534f7d69cdcb506132d9761fcef74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 className="font-italics">modified {moment.utc(this.props.data.updated).fromNow()}</span>
      )
    } else {
      return (
        <span>{moment.utc(this.props.data.published).fromNow()}</span>
      )
    }
  }
}