mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
1e152c666c
* chore: moved app & space from apps to root * chore: modified workspace configuration * chore: modified dockerfiles for space and web * chore: modified icons for space * feat: updated files for new svg icons supported by next-images * chore: added /spaces base path for next * chore: added compose config for space * chore: updated husky configuration * chore: updated workflows for new configuration * chore: changed app name to web * fix: resolved build errors with web * chore: reset file tracing root for both projects * chore: added nginx config for deploy * fix: eslint and tsconfig settings for space app * husky setup fixes based on new dir * eslint fixes * prettier formatting --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
export const renderDateFormat = (date: string | Date | null) => {
|
|
if (!date) return "N/A";
|
|
|
|
var d = new Date(date),
|
|
month = "" + (d.getMonth() + 1),
|
|
day = "" + d.getDate(),
|
|
year = d.getFullYear();
|
|
|
|
if (month.length < 2) month = "0" + month;
|
|
if (day.length < 2) day = "0" + day;
|
|
|
|
return [year, month, day].join("-");
|
|
};
|
|
|
|
/**
|
|
* @description Returns date and month, if date is of the current year
|
|
* @description Returns date, month adn year, if date is of a different year than current
|
|
* @param {string} date
|
|
* @example renderFullDate("2023-01-01") // 1 Jan
|
|
* @example renderFullDate("2021-01-01") // 1 Jan, 2021
|
|
*/
|
|
|
|
export const renderFullDate = (date: string): string => {
|
|
if (!date) return "";
|
|
|
|
const months: string[] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
|
|
const currentDate: Date = new Date();
|
|
const [year, month, day]: number[] = date.split("-").map(Number);
|
|
|
|
const formattedMonth: string = months[month - 1];
|
|
const formattedDay: string = day < 10 ? `0${day}` : day.toString();
|
|
|
|
if (currentDate.getFullYear() === year) return `${formattedDay} ${formattedMonth}`;
|
|
else return `${formattedDay} ${formattedMonth}, ${year}`;
|
|
};
|