Skip to content

Commit

Permalink
fix timeAgo
Browse files Browse the repository at this point in the history
  • Loading branch information
wpdas committed Apr 26, 2024
1 parent a1c144d commit 31d0bfa
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/modules/TimeAgo/timeAgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,37 @@ import en from "./en";

// TODO: Fazer video tutorial disso
// Code builder for "formatTimestamp"
const formatTimestampCode = (timestamp: number) => {
const code = `
(() => {
TimeAgo.addDefaultLocale({
${en}
});
// const formatTimestampCode = (timestamp: number) => {
// const code = `
// (() => {
// TimeAgo.addDefaultLocale({
// ${en}
// });

return new TimeAgo('en-US').format(new Date(${timestamp}));
})()
`;
return code;
};
// return new TimeAgo('en-US').format(new Date(${timestamp}));
// })()
// `;
// return code;
// };

// const timeAgo = {
// formatTimestamp: (timestamp: number, onComplete: (data: string) => void) =>
// ({
// code: formatTimestampCode(timestamp),
// onComplete,
// } as UseModuleProps),
// };

const timeAgo = {
moduleSetup: `
TimeAgo.addDefaultLocale({
${en}
})
`,
formatTimestamp: (timestamp: number, onComplete: (data: string) => void) =>
({
code: formatTimestampCode(timestamp),
setupCode: timeAgo.moduleSetup,
code: `new TimeAgo('en-US').format(new Date(${timestamp}))`,
onComplete,
} as UseModuleProps),
};
Expand Down

0 comments on commit 31d0bfa

Please sign in to comment.