Skip to content

Instantly share code, notes, and snippets.

@GGontijo
Created August 8, 2024 13:51
Show Gist options
  • Save GGontijo/eb8d61e85db64884ebf9356b72d40368 to your computer and use it in GitHub Desktop.
Save GGontijo/eb8d61e85db64884ebf9356b72d40368 to your computer and use it in GitHub Desktop.
Obsidian sprint tasks template
<%*
function getMonday(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6 : 1); // ajustar quando o dia for domingo
return new Date(d.setDate(diff));
}
function formatDate(date) {
let dd = date.getDate();
let mm = date.getMonth() + 1;
return `${dd < 10 ? '0' : ''}${dd}-${mm < 10 ? '0' : ''}${mm}`;
}
let today = new Date();
let monday = getMonday(today);
let friday = new Date(monday);
friday.setDate(monday.getDate() + 4);
let title = `${formatDate(monday)} até ${formatDate(friday)}`;
let filePath = `Sprints/${title}`;
await tp.file.rename(title);
await tp.file.move(filePath);
const tasksString = `
task1
task2
task3
`;
const tasksArray = tasksString.trim().split('\n');
const tasks = tasksArray.map(task => `- [ ] ${task.trim()}`).join('\n');
const trackerEntries = tasksArray.map(task => ({
name: task.trim(),
startTime: null,
endTime: null,
subEntries: null
}));
const trackerJSON = {
entries: trackerEntries
};
tR += tasks + "\n\n";
tR += "```timekeep\n";
tR += JSON.stringify(trackerJSON, null, 2);
tR += "\n```";
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment