1 import { capitalizeFirstLetter, formatPastDate } from "@utils/helpers";
2 import format from "date-fns/format";
3 import parseISO from "date-fns/parseISO";
4 import { Component } from "inferno";
5 import { I18NextService } from "../../services";
6 import { Icon } from "./icon";
8 interface MomentTimeProps {
12 ignoreUpdated?: boolean;
15 function formatDate(input: string) {
16 return format(parseISO(input), "PPPPpppp");
19 export class MomentTime extends Component<MomentTimeProps, any> {
20 constructor(props: any, context: any) {
21 super(props, context);
24 createdAndModifiedTimes() {
25 const updated = this.props.updated;
26 let line = `${capitalizeFirstLetter(
27 I18NextService.i18n.t("created")
28 )}: ${formatDate(this.props.published)}`;
30 line += `\n\n\n${capitalizeFirstLetter(
31 I18NextService.i18n.t("modified")
32 )} ${formatDate(updated)}`;
38 if (!this.props.ignoreUpdated && this.props.updated) {
41 data-tippy-content={this.createdAndModifiedTimes()}
42 className="moment-time font-italics pointer unselectable"
44 <Icon icon="edit-2" classes="icon-inline me-1" />
45 {formatPastDate(this.props.updated)}
49 const published = this.props.published;
52 className="moment-time pointer unselectable"
53 data-tippy-content={formatDate(published)}
55 {formatPastDate(published)}