-
-
Save thecist/e77a299aa7baf3fd63ce4474cb91e787 to your computer and use it in GitHub Desktop.
Source code for due status in Notion Habits View Template by TheCist
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( | |
| first_day, | |
| min( | |
| if(contains(prop("Days"), "Sun"), 0, 7), | |
| if(contains(prop("Days"), "Mon"), 1, 7), | |
| if(contains(prop("Days"), "Tue"), 2, 7), | |
| if(contains(prop("Days"), "Wed"), 3, 7), | |
| if(contains(prop("Days"), "Thu"), 4, 7), | |
| if(contains(prop("Days"), "Fri"), 5, 7), | |
| if(contains(prop("Days"), "Sat"), 6, 7) | |
| ), | |
| last_day, | |
| max( | |
| if(contains(prop("Days"), "Sun"), 0, -1), | |
| if(contains(prop("Days"), "Mon"), 1, -1), | |
| if(contains(prop("Days"), "Tue"), 2, -1), | |
| if(contains(prop("Days"), "Wed"), 3, -1), | |
| if(contains(prop("Days"), "Thu"), 4, -1), | |
| if(contains(prop("Days"), "Fri"), 5, -1), | |
| if(contains(prop("Days"), "Sat"), 6, -1) | |
| ), | |
| prev_day, | |
| max( | |
| if(contains(prop("Days"), "Sun") && mod(day(now()), 7) - 0 > 0, 0, -1), | |
| if(contains(prop("Days"), "Mon") && mod(day(now()), 7) - 1 > 0, 1, -1), | |
| if(contains(prop("Days"), "Tue") && mod(day(now()), 7) - 2 > 0, 2, -1), | |
| if(contains(prop("Days"), "Wed") && mod(day(now()), 7) - 3 > 0, 3, -1), | |
| if(contains(prop("Days"), "Thu") && mod(day(now()), 7) - 4 > 0, 4, -1), | |
| if(contains(prop("Days"), "Fri") && mod(day(now()), 7) - 5 > 0, 5, -1), | |
| if(contains(prop("Days"), "Sat") && mod(day(now()), 7) - 6 > 0, 6, -1) | |
| ), | |
| next_day, | |
| min( | |
| if(contains(prop("Days"), "Sun") && mod(day(now()), 7) <= 0, 0, 7), | |
| if(contains(prop("Days"), "Mon") && mod(day(now()), 7) <= 1, 1, 7), | |
| if(contains(prop("Days"), "Tue") && mod(day(now()), 7) <= 2, 2, 7), | |
| if(contains(prop("Days"), "Wed") && mod(day(now()), 7) <= 3, 3, 7), | |
| if(contains(prop("Days"), "Thu") && mod(day(now()), 7) <= 4, 4, 7), | |
| if(contains(prop("Days"), "Fri") && mod(day(now()), 7) <= 5, 5, 7), | |
| if(contains(prop("Days"), "Sat") && mod(day(now()), 7) <= 6, 6, 7) | |
| ), | |
| week_duration, | |
| ifs( | |
| prop("Repeats Every (Weekly)").empty() || prop("Repeats Every (Weekly)")< 1, | |
| 1, | |
| prop("Repeats Every (Weekly)") | |
| ), | |
| weeks_ahead, | |
| mod( | |
| floor( | |
| dateBetween( | |
| dateSubtract(now(), mod(day(now()), 7), "days"), | |
| dateSubtract(prop("Created time"), mod(day(prop("Created time")), 7), "days"), | |
| "days" | |
| ) / 7 | |
| ), week_duration | |
| ), | |
| weeks_till_next, | |
| if( | |
| weeks_ahead == 0, | |
| week_duration, | |
| weeks_ahead | |
| ), | |
| weeks_till_prev, | |
| week_duration - weeks_ahead, | |
| prev_date, | |
| ifs( | |
| prev_day != -1 && weeks_till_prev == 0, | |
| dateSubtract( | |
| now(), | |
| mod(day(now()), 7) - prev_day, | |
| "days" | |
| ), | |
| dateSubtract( | |
| dateAdd( | |
| now(), | |
| last_day - mod(day(now()), 7), | |
| "days" | |
| ), | |
| weeks_till_prev, | |
| "weeks" | |
| ) | |
| ), | |
| prev_date, | |
| dateSubtract( | |
| dateSubtract( | |
| prev_date, | |
| hour(prev_date), | |
| "hours" | |
| ), | |
| minute(prev_date), | |
| "minute" | |
| ), | |
| next_date, | |
| ifs( | |
| next_day != 7 && weeks_till_next == week_duration, | |
| dateAdd( | |
| now(), | |
| next_day - mod(day(now()), 7), | |
| "days" | |
| ), | |
| dateAdd( | |
| dateSubtract( | |
| now(), | |
| mod(day(now()), 7) - first_day, | |
| "days" | |
| ), | |
| weeks_till_next, | |
| "weeks" | |
| ) | |
| ), | |
| next_date, | |
| dateAdd( | |
| dateAdd( | |
| next_date, | |
| 23 - hour(next_date), | |
| "hours" | |
| ), | |
| 59 - minute(next_date), | |
| "minute" | |
| ), | |
| due_in, | |
| dateBetween(next_date, now(), "days"), | |
| due_in_text, | |
| ifs( | |
| due_in == 0, | |
| "Due Today", | |
| due_in == 1, | |
| "Due Tomorrow", | |
| "Due in " + due_in + " days" | |
| ), | |
| ifs( | |
| prop("Pause Habit"), | |
| "Disabled", | |
| first_day == 7, | |
| "Please set a day", | |
| empty(prop("Last Completed")) == true, | |
| due_in_text, | |
| dateBetween(prop("Last Completed"), prev_date, "days") >= 1 && dateBetween(next_date,prop("Last Completed"), "days") < 1, | |
| "✅ Completed", | |
| due_in_text | |
| ) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment