MCPcopy Create free account
hub / github.com/LevelUpWeb3/app / formatDate

Function formatDate

src/utils/format.ts:101–118  ·  view source on GitHub ↗
(
  date,
  options: { needSub?: boolean; withTime?: boolean; isUnix?: boolean } = {},
)

Source from the content-addressed store, hash-verified

99};
100
101export const formatDate = (
102 date,
103 options: { needSub?: boolean; withTime?: boolean; isUnix?: boolean } = {},
104) => {
105 const { needSub, withTime, isUnix } = options;
106 let finalDate = dayjs.isDayjs(date)
107 ? date
108 : isUnix
109 ? dayjs.unix(date)
110 : dayjs(date);
111 if (needSub) {
112 finalDate = date.subtract(1, "ms");
113 }
114 if (withTime) {
115 return finalDate.format("MMM D, YYYY h:mmA");
116 }
117 return finalDate.format("MMM D, YYYY");
118};
119
120export const trimErrorMessage = (message) => {
121 return message.split("(")[0].trim();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected