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