Files
Rocketmc/apps/frontend/src/composables/date.js
Evan Song abec2e48d4 Add TailwindCSS (#1252)
* Setup TailwindCSS

* Fully setup configuration

* Refactor some tailwind variables
2024-07-06 20:57:32 -07:00

19 lines
465 B
JavaScript

/* eslint-disable no-undef */
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
dayjs.extend(relativeTime);
export const useCurrentDate = () => useState("currentDate", () => Date.now());
export const updateCurrentDate = () => {
const currentDate = useCurrentDate();
currentDate.value = Date.now();
};
export const fromNow = (date) => {
const currentDate = useCurrentDate();
return dayjs(date).from(currentDate.value);
};