diff options
author | Dessalines <tyhou13@gmx.com> | 2020-07-09 20:11:05 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-07-09 20:11:05 -0400 |
commit | d271ae67aa45cd1e185190864facb0cd5e797a23 (patch) | |
tree | 2d720b59bd2485d7f7ffc4a641ab4683445eb20f /ui/src/utils.ts | |
parent | db09730d5f391c37bde87f59ed2ea6f3418034e4 (diff) | |
parent | 961d65c0ee304b97cc3932d7e2a7334a823e2969 (diff) |
Merge branch 'master' into remove_twemoji
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r-- | ui/src/utils.ts | 13 |
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`; |