1 import { Component } from "inferno";
2 import moment from "moment";
3 import { i18n } from "../../i18next";
4 import { capitalizeFirstLetter } 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 moment.locale([...i18n.languages]);
21 createdAndModifiedTimes() {
22 const updated = this.props.updated;
23 let line = `${capitalizeFirstLetter(i18n.t("created"))}: ${this.format(
27 line += `\n\n\n${capitalizeFirstLetter(i18n.t("modified"))} ${this.format(
35 if (!this.props.ignoreUpdated && this.props.updated) {
38 data-tippy-content={this.createdAndModifiedTimes()}
39 className="font-italics pointer unselectable"
41 <Icon icon="edit-2" classes="icon-inline mr-1" />
42 {moment.utc(this.props.updated).fromNow(!this.props.showAgo)}
46 const published = this.props.published;
49 className="pointer unselectable"
50 data-tippy-content={this.format(published)}
52 {moment.utc(published).fromNow(!this.props.showAgo)}
58 format(input: string): string {
59 return moment.utc(input).local().format("LLLL");