-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemplater_Monthly_Todo
More file actions
73 lines (60 loc) · 2.39 KB
/
Copy pathTemplater_Monthly_Todo
File metadata and controls
73 lines (60 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Templater Monthly Todo Template
<%*
const month = await tp.system.prompt("Enter month name (e.g., January, Feb, Mar, etc.)");
const year = parseInt(await tp.system.prompt("Enter year (e.g., 2025)"));
// Map of month names to numbers
const monthMap = {
january: 1, february: 2, march: 3, april: 4, may: 5, june: 6,
july: 7, august: 8, september: 9, october: 10, november: 11, december: 12
};
const monthCaps = month.toUpperCase();
const monthLower = month.toLowerCase();
const monthNumber = monthMap[monthLower];
if (!monthNumber) {
throw new Error(`Invalid month: ${month}`);
}
const daysInMonth = new Date(year, monthNumber, 0).getDate(); // correct number of days
// === RENAME FILE ===
const filename = `${monthCaps} ${year} TODO`;
await tp.file.rename(filename); // This will rename the file to "MAY TODO 2025"
// === HEADER SECTION ===
tR += `___\n\n`;
tR += `>[!abstract]+ **Habits/Records/Monthly Goals:**\n`;
tR += `> - **Habit 1**\n`;
tR += `> - Lorem ipsum dolor sit amet, consectetur adipiscing elit \n`;
tR += `> - **Habit 2**\n`;
tR += `> - Lorem ipsum dolor sit amet, consectetur adipiscing elit \n`;
tR += `> - **Goal 1**\n`;
tR += `> - Lorem ipsum dolor sit amet, consectetur adipiscing elit \n`;
tR += `> - Lorem ipsum dolor sit amet, consectetur adipiscing elit \n`;
tR += `> - **Goal 2s**\n`;
tR += `> - Lorem ipsum dolor sit amet, consectetur adipiscing eli \n\n`;
tR += `>[!tip]- **Monthly TODO:**\n`;
tR += `> - [ ] Duis aute irure dolor in reprehenderit in voluptate \n`
tR += `> - Duis aute irure dolor \n`
tR += `> - [ ] Example 1 \n`
tR += `> - [ ] Example 2 \n`
tR += `> - [ ] Example 3 \n`
tR += `___\n\n`;
// === DATE BLOCK GENERATION ===
function getSuffix(day) {
if (day > 3 && day < 21) return "th";
switch (day % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
for (let day = 1; day <= daysInMonth; day++) {
const date = new Date(year, monthNumber - 1, day);
const weekday = date.toLocaleDateString("en-US", { weekday: "short" });
const suffix = getSuffix(day);
const dayStr = String(day).padStart(2, "0");
const linkDate = `${year}-${String(monthNumber).padStart(2, "0")}-${dayStr}`;
tR += `**${monthCaps} ${day}${suffix} - ${weekday} --------**\n`;
tR += `##### Tasks:\n - [ ] \n - [ ] \n - [ ] \n\n`;
tR += `###### Events:\n- \n- \n- \n`;
tR += `###### Daily log:\n[[${linkDate}]]\n\n\n`;
}
%>