Fix date rendering for missing date values (#580)

* Fix date rendering when missing date value
* Move scene studio overlay within scene card
This commit is contained in:
WithoutPants
2020-05-27 09:34:46 +10:00
committed by GitHub
parent 4ec6d62e01
commit 1110e9c311
5 changed files with 20 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
import { IntlShape } from "react-intl";
// Typescript currently does not implement the intl Unit interface
type Unit =
| "byte"
@@ -128,6 +130,14 @@ const sanitiseURL = (url?: string, siteURL?: URL) => {
return `https://${url}`;
};
const formatDate = (intl: IntlShape, date?: string) => {
if (!date) {
return "";
}
return intl.formatDate(date, { format: "long" });
};
const TextUtils = {
truncate,
fileSize,
@@ -139,6 +149,7 @@ const TextUtils = {
sanitiseURL,
twitterURL,
instagramURL,
formatDate,
};
export default TextUtils;