1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-21 06:21:17 -04:00

add Mastodon link

This commit is contained in:
2022-11-17 14:10:00 -05:00
parent d4b806dfcf
commit db6594faa7
7 changed files with 515 additions and 452 deletions

View File

@@ -15,14 +15,14 @@ const IsomorphicDayJs = (date?: dayjs.ConfigType): dayjs.Dayjs => {
dayjs.extend(dayjsLocalizedFormat);
dayjs.extend(dayjsAdvancedFormat);
return dayjs(date).locale("en");
return dayjs(date).locale("en").tz(timeZone).clone();
};
// simple wrapper around dayjs.format() to normalize timezone across the site, both server and client side, to prevent
// hydration errors by returning an instance of dayjs with these defaults set.
// date defaults to now, format defaults to ISO 8601 (e.g. 2022-04-07T21:53:33-04:00)
export const formatDate = (date?: dayjs.ConfigType, formatStr?: string): string => {
return IsomorphicDayJs(date).tz(timeZone).format(formatStr);
return IsomorphicDayJs(date).format(formatStr);
};
// returns the human-friendly difference between now and given date (e.g. "5 minutes", "9 months", etc.)