Compare commits
3 Commits
aeb1d62895
...
1.0.4
| Author | SHA1 | Date | |
|---|---|---|---|
| f5e4a16aff | |||
| 9014f086d6 | |||
| d4f2af179f |
17
main.js
17
main.js
@@ -924,9 +924,20 @@ var FocusTaskPlugin = class extends import_obsidian3.Plugin {
|
||||
formatDailyNoteDate(format) {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
||||
const day = now.getDate().toString().padStart(2, "0");
|
||||
return format.replace("YYYY", year.toString()).replace("YY", year.toString().slice(-2)).replace("MM", month).replace("M", (now.getMonth() + 1).toString()).replace("DD", day).replace("D", now.getDate().toString()).replace("dddd", now.toLocaleDateString("en-US", { weekday: "long" })).replace("ddd", now.toLocaleDateString("en-US", { weekday: "short" })).replace("MMMM", now.toLocaleDateString("en-US", { month: "long" })).replace("MMM", now.toLocaleDateString("en-US", { month: "short" }));
|
||||
const month = now.getMonth() + 1;
|
||||
const day = now.getDate();
|
||||
let result = format;
|
||||
result = result.replace(/YYYY/g, year.toString());
|
||||
result = result.replace(/YY/g, year.toString().slice(-2));
|
||||
result = result.replace(/MMMM/g, now.toLocaleDateString("en-US", { month: "long" }));
|
||||
result = result.replace(/MMM/g, now.toLocaleDateString("en-US", { month: "short" }));
|
||||
result = result.replace(/MM/g, month.toString().padStart(2, "0"));
|
||||
result = result.replace(/(?<![A-Za-z])M(?![A-Za-z])/g, month.toString());
|
||||
result = result.replace(/dddd/g, now.toLocaleDateString("en-US", { weekday: "long" }));
|
||||
result = result.replace(/ddd/g, now.toLocaleDateString("en-US", { weekday: "short" }));
|
||||
result = result.replace(/DD/g, day.toString().padStart(2, "0"));
|
||||
result = result.replace(/(?<![A-Za-z])D(?![A-Za-z])/g, day.toString());
|
||||
return result;
|
||||
}
|
||||
async getOrCreateDailyNote() {
|
||||
const { vault } = this.app;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "focus-task",
|
||||
"name": "Focus Task",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "A Blitzit-inspired task management and focus timer plugin. Plan your day, track time with Pomodoro technique, and crush your tasks with satisfying checkoffs.",
|
||||
"author": "Crib",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "focus-task",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "A Blitzit-inspired task management and focus timer plugin for Obsidian",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
41
src/main.ts
41
src/main.ts
@@ -598,21 +598,32 @@ export default class FocusTaskPlugin extends Plugin {
|
||||
formatDailyNoteDate(format: string): string {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = now.getDate().toString().padStart(2, '0');
|
||||
const month = now.getMonth() + 1;
|
||||
const day = now.getDate();
|
||||
|
||||
// Handle common date format tokens
|
||||
return format
|
||||
.replace('YYYY', year.toString())
|
||||
.replace('YY', year.toString().slice(-2))
|
||||
.replace('MM', month)
|
||||
.replace('M', (now.getMonth() + 1).toString())
|
||||
.replace('DD', day)
|
||||
.replace('D', now.getDate().toString())
|
||||
.replace('dddd', now.toLocaleDateString('en-US', { weekday: 'long' }))
|
||||
.replace('ddd', now.toLocaleDateString('en-US', { weekday: 'short' }))
|
||||
.replace('MMMM', now.toLocaleDateString('en-US', { month: 'long' }))
|
||||
.replace('MMM', now.toLocaleDateString('en-US', { month: 'short' }));
|
||||
// Use placeholders to avoid replacement conflicts
|
||||
// Replace longer tokens first, use unique placeholders
|
||||
let result = format;
|
||||
|
||||
// Year tokens
|
||||
result = result.replace(/YYYY/g, year.toString());
|
||||
result = result.replace(/YY/g, year.toString().slice(-2));
|
||||
|
||||
// Month tokens (longer first)
|
||||
result = result.replace(/MMMM/g, now.toLocaleDateString('en-US', { month: 'long' }));
|
||||
result = result.replace(/MMM/g, now.toLocaleDateString('en-US', { month: 'short' }));
|
||||
result = result.replace(/MM/g, month.toString().padStart(2, '0'));
|
||||
// Only replace standalone M, not part of other tokens
|
||||
result = result.replace(/(?<![A-Za-z])M(?![A-Za-z])/g, month.toString());
|
||||
|
||||
// Day tokens (longer first)
|
||||
result = result.replace(/dddd/g, now.toLocaleDateString('en-US', { weekday: 'long' }));
|
||||
result = result.replace(/ddd/g, now.toLocaleDateString('en-US', { weekday: 'short' }));
|
||||
result = result.replace(/DD/g, day.toString().padStart(2, '0'));
|
||||
// Only replace standalone D, not part of other tokens
|
||||
result = result.replace(/(?<![A-Za-z])D(?![A-Za-z])/g, day.toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async getOrCreateDailyNote(): Promise<TFile | null> {
|
||||
@@ -965,4 +976,4 @@ class FocusTaskSettingTab extends PluginSettingTab {
|
||||
</p>
|
||||
`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"1.0.3": "0.15.0"
|
||||
"1.0.4": "0.15.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user