summaryrefslogtreecommitdiffstats
path: root/ui/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r--ui/src/utils.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/src/utils.ts b/ui/src/utils.ts
index b3d0f368..2f06b70c 100644
--- a/ui/src/utils.ts
+++ b/ui/src/utils.ts
@@ -54,6 +54,7 @@ import markdown_it_container from 'markdown-it-container';
import emojiShortName from 'emoji-short-name';
import Toastify from 'toastify-js';
import tippy from 'tippy.js';
+import moment from 'moment';
export const repoUrl = 'https://github.com/LemmyNet/lemmy';
export const helpGuideUrl = '/docs/about_guide.html';
@@ -487,6 +488,18 @@ export function showAvatars(): boolean {
);
}
+export function isCakeDay(published: string): boolean {
+ // moment(undefined) or moment.utc(undefined) returns the current date/time
+ // moment(null) or moment.utc(null) returns null
+ const userCreationDate = moment.utc(published || null).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`;