ipad commit 2025-12-17-01-15
This commit is contained in:
41
새로운 7.txt
Normal file
41
새로운 7.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
<%*
|
||||
function getPreviousWeek(year, week) {
|
||||
if (week === 1) {
|
||||
year -= 1;
|
||||
let lastWeekOfYear = getISOWeekNumber(new Date(year, 11, 28));
|
||||
return `${year}-W${String(lastWeekOfYear).padStart(2, '0')}`;
|
||||
} else {
|
||||
week -= 1;
|
||||
return `${year}-W${String(week).padStart(2, '0')}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getISOWeekNumber(date) {
|
||||
let day = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
let dayNum = day.getDay() || 7;
|
||||
day.setDate(day.getDate() + 4 - dayNum);
|
||||
let yearStart = new Date(day.getFullYear(), 0, 1);
|
||||
return Math.ceil((((day - yearStart) / 86400000) + 1) / 7);
|
||||
}
|
||||
|
||||
let [year, week] = tp.file.title.split("-W").map(Number);
|
||||
let lastWeek = getPreviousWeek(year, week);
|
||||
let lastWeekPath = "10. Planner/12. Weekly/" + lastWeek;
|
||||
let section = "## 다음 주 계획";
|
||||
let should_include = false;
|
||||
let sectionContent = "";
|
||||
|
||||
let lwfile = tp.file.find_tfile(lastWeekPath);
|
||||
if(lwfile) {
|
||||
const content = await app.vault.read(lwfile);
|
||||
if(content.includes(section)) {
|
||||
let startIndex = content.indexOf(section) + section.length;
|
||||
let endIndex = content.indexOf('\n##', startIndex);
|
||||
endIndex = endIndex === -1 ? content.length : endIndex;
|
||||
sectionContent = content.substring(startIndex, endIndex).trim();
|
||||
should_include = sectionContent.length > 0;
|
||||
}
|
||||
}
|
||||
|
||||
tR += should_include ? sectionContent : "없습니다😀";
|
||||
%>
|
||||
Reference in New Issue
Block a user