From 8fe8836bc263be11895fafa958409499c9e9fc9d Mon Sep 17 00:00:00 2001 From: Filip785 Date: Wed, 8 Jul 2020 19:46:18 +0200 Subject: Updates to PR as requested --- ui/src/utils.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ui/src/utils.ts') diff --git a/ui/src/utils.ts b/ui/src/utils.ts index f65ca4e3..3ccaae12 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -53,6 +53,7 @@ import emojiShortName from 'emoji-short-name'; import Toastify from 'toastify-js'; import tippy from 'tippy.js'; import EmojiButton from '@joeattardi/emoji-button'; +import moment from 'moment'; export const repoUrl = 'https://github.com/LemmyNet/lemmy'; export const helpGuideUrl = '/docs/about_guide.html'; @@ -489,6 +490,16 @@ export function showAvatars(): boolean { ); } +export function isCakeDay(creator_published: string): boolean { + const userCreationDate = moment.utc(creator_published).local(); + const currentDate = moment(new Date()); + + return ( + userCreationDate.date() === currentDate.date() && + userCreationDate.month() === currentDate.month() + ); +} + // Converts to image thumbnail export function pictrsImage(hash: string, thumbnail: boolean = false): string { let root = `/pictrs/image`; -- cgit v1.2.3