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 {
11 ignoreUpdated?: boolean;
14 export class MomentTime extends Component<MomentTimeProps, any> {
15 constructor(props: any, context: any) {
16 super(props, context);
18 let lang = getLanguages();
23 createdAndModifiedTimes() {
24 let updated = this.props.updated;
25 let line = `${capitalizeFirstLetter(i18n.t("created"))}: ${this.format(
29 line += `\n\n\n${capitalizeFirstLetter(i18n.t("modified"))} ${this.format(
37 if (!this.props.ignoreUpdated && this.props.updated) {
40 data-tippy-content={this.createdAndModifiedTimes()}
41 className="font-italics pointer unselectable"
43 <Icon icon="edit-2" classes="icon-inline mr-1" />
44 {moment.utc(this.props.updated).fromNow(!this.props.showAgo)}
48 let published = this.props.published;
51 className="pointer unselectable"
52 data-tippy-content={this.format(published)}
54 {moment.utc(published).fromNow(!this.props.showAgo)}
60 format(input: string): string {
61 return moment.utc(input).local().format("LLLL");