SmartBlocks
SmartBlocks copied to clipboard
get the date ____ days from today
✂️ Copy of your #42SmartBlock from Roam
- #42SmartBlock fromtoday
- <%JAVASCRIPT:
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var today = new Date();
difference = parseInt(prompt('How many days from today?'))*24*3600*1000;
var d = new Date(today.getTime() + difference);
var d_str = `${d.getDate()}`;
if (d_str.length==2 && d_str[0]==1){
var th = 'th';
}
else {
if (d.getDate()%10 == 1){
var th = 'st';
}
else if (d.getDate()%10 == 2){
var th = 'nd';
}
else if (d.getDate()%10 == 3){
var th = 'rd';
}
else {
var th = 'th';
}
}
msg = `[[${months[d.getMonth()]} ${d.getDate()}${th}, ${d.getFullYear()}]]`;
return msg
%>
📋 Describe the SmartBlock
- type
jj fromtoday
- enter a number in the pop-up box
- will return the date X days from today
✅ Describe any prerequisites or dependencies that are required for this SmartBlock
Roam42
please paste the code part in a javascript codeblock, and place it in the the line after <%JAVASCRIPT:
, and the line before %>
(in the same block)
make sure the layout looks like the screenshots below (codes in the screenshots are outdated)
📷 Screenshot of your #42SmartBlock workflow/template from Roam