Last active
September 16, 2023 15:48
-
-
Save typeoneerror/35cb4201d982794d56e2c5945e4213a3 to your computer and use it in GitHub Desktop.
Days left in Notion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lets( | |
nowVal, now(), | |
/* We need now as just a date with no time */ | |
nowDate, nowVal.formatDate("YYYY-MM-DD").parseDate(), | |
dueDate, prop("Due Date").formatDate("YYYY-MM-DD").parseDate(), | |
/* Days between now and the due date */ | |
days, dateBetween(dueDate, nowDate, "days"), | |
/* Now we switch on the conditions */ | |
ifs( | |
/* Date is unset */ | |
empty(prop("Due Date")), "No date".style("grey", "i"), | |
/* No diff is today */ | |
days == 0, "Today".style("red"), | |
/* +1 is tomorrow */ | |
days == 1, "Tomorrow".style("orange"), | |
/* -1 is yesterday */ | |
days == -1, "❗️ Yesterday".style("red", "b"), | |
/* well overdue! */ | |
days < -1, ("‼️ " + abs(days) + " days ago").style("red", "b"), | |
/* positive days remain */ | |
days + " days left" | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment