Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO: Could be done with Array.prototype.reducer very nicely
parts.forEach((token) => {
if (token === '{{') {
paramActive = true;
} else if (token === '}}') {
paramActive = false;
} else if (paramActive) {
const param = this.getParam(token);
message.push((<span>{param}</span>));
} else {
message.push(token);
}
});
const createdDate = this.convertUTCDateToLocalDate(new Date(createdAt));
const { value, unit } = selectUnit(createdDate, Date.now());
return (
<li>
<div>
</div>
{message}
</li>
);
}
}
export const TimeAgo = (props: Props) => {
const { className, before, date } = props;
let dateNumber: number = typeof date === "number" ? date : +new Date(date);
let dateString: string =
typeof date === "number" ? new Date(date).toISOString() : date;
const { value, unit } = selectUnit(dateNumber);
// TODO: since we're passing a relative value, do we need to update it
// ourselves now? If so, do we want to? Using hooks maybe?
// TODO: review react-hint usage
return (
<span title="{dateString}">
{before ? <>{before} : null}
</span>
);
};
export default () => {
const { value, unit } = selectUnit(Date.now())
return (
<p>
</p>
)
}
export const FormattedRelative = (props: FormattedRelativeProps) => {
const { value, unit } = selectUnit(props.value);
return ;
};