Open Calhistorian opened 3 years ago
@Calhistorian here's a pretty basic implementation. It will ask for a month/day and defaults to the current date if input is left blank. Could probably be adapted to grab the date from the page title if in a daily note. Hasn't been tested for every possible edge case, but generally seems to work.
credit for getWeek function: https://stackoverflow.com/questions/6117814/get-week-of-year-in-javascript-like-in-php
javascript Date.prototype.getWeek = function() { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); } let date = roam42.smartBlocks.activeWorkflow.vars.date return new Date(date ? date : new Date()).getWeek()
%>Slightly different example
- #42SmartBlock Get ISO Week Number Date
- <%JAVASCRIPT:```javascript
Date.prototype.getWeekNumber = function(){
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
var dayNum = d.getUTCDay() || 7;
d.setUTCDate(d.getUTCDate() + 4 - dayNum);
var yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));
return Math.ceil((((d - yearStart) / 86400000) + 1)/7)
};
let date = roam42.smartBlocks.activeWorkflow.vars.date
let weekNumber = new Date(date ? date : new Date()).getWeekNumber()
let year = new Date(date ? date : new Date()).getFullYear()
return "[[" + year + "-W" + weekNumber + "]]"```%>
Humm, I could be wrong but this is actually implemented now, using ww as format
Example: <%DATE:This week,ww%>
📋 Describe the new feature/idea/enhancement you are requesting
Would be great to add to previous date commands to get the week number.
🔑 Why do you want this?
Being able to track weekly items by their consecutive week number is useful in any number of situations.
⚠️ Is your feature request related to a problem? Please describe.
No.
🔨 Describe any alternatives you've considered
💻 Environment
Platform: macOS
Browser: Chrome
📷 Additional Info (Screenshots, GIFs, etc.)