mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-21 06:41:17 -04:00
only reveal a db record via /api/hits
if it matches a real page
This commit is contained in:
@@ -21,13 +21,13 @@ const IsomorphicDayJs = (date?: dayjs.ConfigType): dayjs.Dayjs => {
|
||||
// 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) => {
|
||||
export const formatDate = (date?: dayjs.ConfigType, formatStr?: string): string => {
|
||||
return IsomorphicDayJs(date).tz(timeZone).format(formatStr);
|
||||
};
|
||||
|
||||
// returns the human-friendly difference between now and given date (e.g. "5 minutes", "9 months", etc.)
|
||||
// set `{ suffix: true }` to include the "... ago" or "in ..." for past/future
|
||||
export const formatTimeAgo = (date: dayjs.ConfigType, options?: { suffix?: boolean }) => {
|
||||
export const formatTimeAgo = (date: dayjs.ConfigType, options?: { suffix?: boolean }): string => {
|
||||
return IsomorphicDayJs().isBefore(date)
|
||||
? IsomorphicDayJs(date).toNow(!options?.suffix)
|
||||
: IsomorphicDayJs(date).fromNow(!options?.suffix);
|
||||
|
Reference in New Issue
Block a user