1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-26 08:11:17 +02:00

add subs details in profile modal

This commit is contained in:
Kushagra Gour
2024-03-19 15:53:02 +05:30
parent 22a4361baa
commit 14bc964aa4
8 changed files with 284 additions and 46 deletions

View File

@@ -205,6 +205,41 @@ export function getHumanDate(timestamp) {
return retVal;
}
/**
* Convert any date-ish string/obj to human readable form -> Jul 02, 2021
* @param {string?object} date date to be formatted
* @returns string
*/
export function getHumanReadableDate(
date,
{ showTime = true, utc = false } = {}
) {
if (!date) return '';
let d = typeof date.toDate === 'function' ? date.toDate() : new Date(date);
if (utc) {
d = new Date(
Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours())
);
}
let options = {
year: 'numeric',
month: 'short',
day: 'numeric'
};
if (showTime) {
options = {
...options,
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
};
}
const dateTimeString = d.toLocaleString(false, options);
return dateTimeString;
}
// create a one-time event
export function once(node, type, callback) {
// create event