From 3a2ebd1dda26d37e3aed2b2f1d53b5dcbba8e4b7 Mon Sep 17 00:00:00 2001 From: Locke Birdsey Date: Sat, 12 Apr 2025 09:15:50 +0300 Subject: [PATCH] add 3char days to dateformatter --- journal-entry/info.json | 2 +- journal-entry/journal-entry.qml | 6 +++++- quick-commands/info.json | 2 +- quick-commands/quick-commands.qml | 8 +++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/journal-entry/info.json b/journal-entry/info.json index 089d1dc..d9dd5f1 100644 --- a/journal-entry/info.json +++ b/journal-entry/info.json @@ -3,7 +3,7 @@ "identifier": "journal-entry", "script": "journal-entry.qml", "resources": ["calendar-window.qml"], - "version": "1.7.0", + "version": "1.8.0", "minAppVersion": "20.4.16", "authors": ["@pbek", "@sanderboom", "@kantrol", "@nico2sh"], "description": "This script creates menu items and buttons to create or jump to the current date's (or tomorrow's date) journal entry. And formats the title based on a date placeholder. It also allows to open a calendar to choose the date." diff --git a/journal-entry/journal-entry.qml b/journal-entry/journal-entry.qml index f3353e4..c856f66 100644 --- a/journal-entry/journal-entry.qml +++ b/journal-entry/journal-entry.qml @@ -7,6 +7,8 @@ import com.qownnotes.noteapi 1.0 */ QtObject { id: journalEntry + readonly property variant _SHORT_DAYS_EN: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] + property string defaultFolder property string defaultTags @@ -31,7 +33,7 @@ QtObject { { "identifier": "noteTitleFormat", "name": "Title Format", - "description": "How the journal title should be formatted, use date format placeholders inside curly braces. YYYY: year, MM: month, DD: day, WW: week, HH: hours, mm: minutes, ss: seconds. For example \"Journal {YYYYMMDD}\" will return \"Journal 20240928\". You can have monthly or weekly journals instead of daily by formatting the date to the week or monthly level, or one journal file per entry by including the hour, minutes and seconds.", + "description": "How the journal title should be formatted, use date format placeholders inside curly braces. YYYY: year, MM: month, DD: day, WW: week, HH: hours, mm: minutes, ss: seconds, ddd: short day of the week e.g. 'Mon'. For example \"Journal {YYYYMMDD}\" will return \"Journal 20240928\". You can have monthly or weekly journals instead of daily by formatting the date to the week or monthly level, or one journal file per entry by including the hour, minutes and seconds.", "type": "string", "default": "Journal {YYYYMMDD}" }, @@ -137,6 +139,7 @@ QtObject { } function formatDate(date, format) { let day = date.getDate(); + let dayOfWeek = _SHORT_DAYS_EN[date.getDay()]; let month = date.getMonth() + 1; //getMonth() returns 0-11 so we must add 1 let week = getWeekNumber(date); let year = date.getFullYear(); @@ -156,6 +159,7 @@ QtObject { format = format.replace('WW', week); format = format.replace('MM', month); format = format.replace('DD', day); + format = format.replace('ddd', dayOfWeek); format = format.replace('YYYY', year); format = format.replace('HH', hours); format = format.replace('mm', minutes); diff --git a/quick-commands/info.json b/quick-commands/info.json index de8a9fe..e439e8f 100644 --- a/quick-commands/info.json +++ b/quick-commands/info.json @@ -4,7 +4,7 @@ "script": "quick-commands.qml", "authors": ["@LockeBirdsey"], "platforms": ["linux", "macos", "windows"], - "version": "0.0.1", + "version": "0.1.0", "minAppVersion": "25.4.1", "description": "Short commands to help with repetive and/or annoying things to write frequently such as timestamps.\n\nEach command starts with a backslash (\\) and a single word for the command. Select the autocomplete option you desire and the command text will be replace.\n\nDefault commands are: today, tomorrow, yesterday, now, week.\n\nCustom commands can also be specified but are limited to simple text replacement." } diff --git a/quick-commands/quick-commands.qml b/quick-commands/quick-commands.qml index eeeeb57..332ea70 100644 --- a/quick-commands/quick-commands.qml +++ b/quick-commands/quick-commands.qml @@ -14,10 +14,13 @@ Script { readonly property int _MILLI_DAY: 86400000 readonly property string _WEEKWWYYYY: "wWW-YYYY" readonly property string _WWYYYY: "WW-YYYY" - // DateFormats readonly property string _YYYYMMDD: "YYYY-MM-DD" + readonly property string _DDDDMY: "ddd (DD-MM-YYYY)" + readonly property variant _SHORT_DAYS_EN: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] + property var commands property string customCommands + property variant settingsVariables: [ { "identifier": "customCommands", @@ -52,6 +55,7 @@ Script { timeList.push(formatDate(date, _DDMM)); timeList.push(formatDate(date, _YYYYMMDD)); timeList.push(formatDate(date, _DDMMYYYY)); + timeList.push(formatDate(date, _DDDDMY)); timeList.push(formatDate(date, _FULL)); return timeList; } @@ -59,6 +63,7 @@ Script { // Taken from https://github.com/qownnotes/scripts/blob/master/journal-entry/journal-entry.qml function formatDate(date, format) { let day = date.getDate(); + let dayOfWeek = _SHORT_DAYS_EN[date.getDay()]; let month = date.getMonth() + 1; //getMonth() returns 0-11 so we must add 1 let week = getWeekNumber(date); let year = date.getFullYear(); @@ -78,6 +83,7 @@ Script { format = format.replace('WW', week); format = format.replace('MM', month); format = format.replace('DD', day); + format = format.replace('ddd', dayOfWeek); format = format.replace('YYYY', year); format = format.replace('HH', hours); format = format.replace('mm', minutes);