**__Do Not Modify__**
<%DATEBASIS:DNP%>
<%NOBLOCKOUTPUT%>
**__Set the event description for the repeating event.__**
<%SET:eventDescription,New Years Eve%>
<%NOBLOCKOUTPUT%>
**__Set the start date for the repeating event.__**
<%SET:startDate,<%DATE: Dec 31 2017 %>%>
<%NOBLOCKOUTPUT%>
**__Set the period for the event: daily, weekly, monthly, yearly.__**
<%SET:period,yearly%>
<%NOBLOCKOUTPUT%>
**__Set number of days in advance threshold: 1 = day before, 30 = 30 days before.__**
<%SET:daysBefore,20%>
<%NOBLOCKOUTPUT%>
**__Variable to hold the next event date. (Do Not Modify)__**
<%SET:nextEventDate,0%>
<%NOBLOCKOUTPUT%>
**__Variable to hold days remaining before event. (Do Not Modify)__**
<%SET:daysRemaining,0%>
<%NOBLOCKOUTPUT%>
<%JAVASCRIPT:```javascript
var startDate = roam42.smartBlocks.activeWorkflow.vars["startDate"];
var period = roam42.smartBlocks.activeWorkflow.vars["period"];
var daysBefore = roam42.smartBlocks.activeWorkflow.vars["daysBefore"];
startDate = startDate.trim().split("[").join("").split("]").join("").replace("#","");
startDate = startDate.replace("st,",",").replace("rd,",",").replace("th,",",").replace("nd,",",");
period = period.toUpperCase();
var start = new Date(Date.parse(startDate));
var next = new Date(Date.parse(startDate));
var today = new Date();
- ````
<%IFTRUE:<%GET:daysRemaining%> < <%GET:daysBefore%>%> <%GET:eventDescription%> is in <%GET:daysRemaining%> days
📋 Describe the SmartBlock
This SmartBlock uses 4 settings ...
1. eventDescription (The name of your event; ex, New Years Eve)
2. startDate (The base date for the event; ex, Dec 31 1900) (do not use commas in date)
3. period (How frequently does the event occur; ex, yearly)
4. daysBefore (How many days before the next event do you want to include it; ex, 10)
... to determine how far in the future the next event will occur.
The nextEventDate and daysRemaining (rounded to the nearest whole day) will be returned.
✅ Describe any prerequisites or dependencies that are required for this SmartBlock
None.
📷 Screenshot of your #42SmartBlock workflow/template from Roam
💡 Additional Info
This SmartBlock is intended to be duplicated for each event for which you want a reminder on your Daily Notes pages and can be included on your Daily Notes pages (typically by way of a template) using <%SMARTBLOCK:Repeating Events%> -- for example, <%SMARTBLOCK:New Years Eve%> if you had a copy called New Years Eve.
✂️ Copy of your #42SmartBlock from Roam
startDate = startDate.trim().split("[").join("").split("]").join("").replace("#",""); startDate = startDate.replace("st,",",").replace("rd,",",").replace("th,",",").replace("nd,",","); period = period.toUpperCase();
var start = new Date(Date.parse(startDate)); var next = new Date(Date.parse(startDate)); var today = new Date();
next.setFullYear(today.getFullYear());
if(period == "DAILY") { roam42.smartBlocks.activeWorkflow.vars["daysBefore"] = 366; }
if(period == "WEEKLY") { next.setDate(next.getDate()+7) }
if(period == "MONTHLY"){ if(next < today) { next.setMonth(next.getMonth()+1); } }
if(period == "YEARLY") { next.setFullYear(today.getFullYear()); if(next < today) { next.setFullYear(next.getFullYear()+1) } }
var days = Math.round((next - today) / 1000 / 60 / 60 /24);
roam42.smartBlocks.activeWorkflow.vars["nextEventDate"] = next.toDateString(); roam42.smartBlocks.activeWorkflow.vars["daysRemaining"] = days;
return(next.toDateString());```%> <%NOBLOCKOUTPUT%>
📋 Describe the SmartBlock
This SmartBlock uses 4 settings ...
... to determine how far in the future the next event will occur.
The nextEventDate and daysRemaining (rounded to the nearest whole day) will be returned.
✅ Describe any prerequisites or dependencies that are required for this SmartBlock
None.
📷 Screenshot of your #42SmartBlock workflow/template from Roam
💡 Additional Info
This SmartBlock is intended to be duplicated for each event for which you want a reminder on your Daily Notes pages and can be included on your Daily Notes pages (typically by way of a template) using
<%SMARTBLOCK:Repeating Events%>
-- for example,<%SMARTBLOCK:New Years Eve%>
if you had a copy called New Years Eve.https://www.loom.com/share/35b9d3211b9e41128f26528e2f2f862a