1 import { Component } from "inferno";
2 import moment from "moment";
3 import { i18n } from "../../i18next";
4 import { capitalizeFirstLetter, getLanguages } 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 = getLanguages();
26 createdAndModifiedTimes() {
27 let created = this.props.data.published || this.props.data.when_;
31 ${capitalizeFirstLetter(i18n.t("created"))}: ${this.format(created)}
34 ${capitalizeFirstLetter(i18n.t("modified"))} ${this.format(
35 this.props.data.updated
42 if (!this.props.ignoreUpdated && this.props.data.updated) {
45 data-tippy-content={this.createdAndModifiedTimes()}
46 data-tippy-allowHtml={true}
47 className="font-italics pointer unselectable"
49 <Icon icon="edit-2" classes="icon-inline mr-1" />
50 {moment.utc(this.props.data.updated).fromNow(!this.props.showAgo)}
54 let created = this.props.data.published || this.props.data.when_;
57 className="pointer unselectable"
58 data-tippy-content={this.format(created)}
60 {moment.utc(created).fromNow(!this.props.showAgo)}
66 format(input: string): string {
67 return moment.utc(input).local().format("LLLL");