From 59a53e695b28144f8f788469dad7865499d95d79 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Thu, 23 Sep 2021 10:09:27 +0100 Subject: [PATCH] Further refine date format tokens for day of year and weekday number See https://github.com/Jermolene/TiddlyWiki5/commit/f223896c263ffb2919ae1f7ac77b7630a263bedc --- core/modules/utils/utils.js | 10 +++++----- editions/tw5.com/tiddlers/features/DateFormat.tid | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 38201c537..1e6b7cec2 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -383,18 +383,18 @@ exports.formatDateString = function(date,template) { [/^0WW/, function() { return $tw.utils.pad($tw.utils.getWeek(date)); }], - [/^0dddd/, function() { + [/^0ddddd/, function() { return $tw.utils.pad(Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24),3); }], - [/^dddd/, function() { + [/^ddddd/, function() { return Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24); }], + [/^dddd/, function() { + return [7,1,2,3,4,5,6][date.getDay()]; + }], [/^ddd/, function() { return $tw.language.getString("Date/Short/Day/" + date.getDay()); }], - [/^dd/, function() { - return [7,1,2,3,4,5,6][date.getDay()]; - }], [/^mmm/, function() { return $tw.language.getString("Date/Short/Month/" + (date.getMonth() + 1)); }], diff --git a/editions/tw5.com/tiddlers/features/DateFormat.tid b/editions/tw5.com/tiddlers/features/DateFormat.tid index 652ee21ca..fbc7c5b93 100644 --- a/editions/tw5.com/tiddlers/features/DateFormat.tid +++ b/editions/tw5.com/tiddlers/features/DateFormat.tid @@ -7,11 +7,11 @@ type: text/vnd.tiddlywiki When used to display date values (with the `format` attribute set to ''date''), the ViewWidget accepts a `template` attribute that allows the format of the date values to be specified. The format string is processed with the following substitutions: |!Token |!Substituted Value | -|`dddd` |Day of year (1 to 365, or 366 for leap years) | -|`0dddd` |Zero padded day of year (001 to 365, or 366 for leap years) | +|`ddddd` |<<.from-version "5.2.0">> Day of year (1 to 365, or 366 for leap years) | +|`0ddddd` |<<.from-version "5.2.0">> Zero padded day of year (001 to 365, or 366 for leap years) | |`DDD` |Day of week in full (eg, "Monday") | |`ddd` |Short day of week (eg, "Mon") | -|`dd` |<<.from-version "5.2.0">> Weekday number from 1 through 7, beginning with Monday and ending with Sunday | +|`dddd` |<<.from-version "5.2.0">> Weekday number from 1 through 7, beginning with Monday and ending with Sunday | |`DD` |Day of month | |`0DD` |Adds a leading zero | |`DDth` |Adds a suffix |