1 import { Component } from "inferno";
2 import moment from "moment";
3 import { i18n } from "../../i18next";
4 import { capitalizeFirstLetter, getMomentLanguage } from "../../utils";
5 import { Icon } from "./icon";
7 interface MomentTimeProps {
14 ignoreUpdated?: boolean;
17 export class MomentTime extends Component<MomentTimeProps, any> {
18 constructor(props: any, context: any) {
19 super(props, context);
21 let lang = getMomentLanguage();
27 if (!this.props.ignoreUpdated && this.props.data.updated) {
30 data-tippy-content={`${capitalizeFirstLetter(
32 )} ${this.format(this.props.data.updated)}`}
33 className="font-italics pointer unselectable"
35 <Icon icon="edit-2" classes="icon-inline mr-1" />
36 {moment.utc(this.props.data.updated).fromNow(!this.props.showAgo)}
40 let str = this.props.data.published || this.props.data.when_;
43 className="pointer unselectable"
44 data-tippy-content={this.format(str)}
46 {moment.utc(str).fromNow(!this.props.showAgo)}
52 format(input: string): string {
53 return moment.utc(input).local().format("LLLL");