1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-04-21 10:13:18 +00:00

Stringify derived fields for tiddlywiki.files (#9025)

Otherwise, when serializing the tiddlers as JSON when loading plugins,
derived values may end up with the incorrect values.

Take the `modified` field for example - without stringification, it ends
up as something like `new Date(2025, 3, 12, 6, 56, 23)`, which then gets
serialized as `"2025-04-12T11:56:23.000Z"` (in my timezone), rather than
`"20250412115623000"`.  The string `"2025-04-12T11:56:23.000Z"` trips up
TiddlyWiki's date parser upon load, and it gets parsed as
`20250101000000000` instead.

Fixes GH #9021
This commit is contained in:
Rob Hoelz 2025-04-14 12:33:18 -05:00 committed by GitHub
parent 1e2ce0bc80
commit 866e55954f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2000,7 +2000,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
var value = tiddler[name];
switch(fieldInfo.source) {
case "subdirectories":
value = path.relative(rootPath, filename).split(path.sep).slice(0, -1);
value = $tw.utils.stringifyList(path.relative(rootPath, filename).split(path.sep).slice(0, -1));
break;
case "filepath":
value = path.relative(rootPath, filename).split(path.sep).join('/');
@ -2021,10 +2021,10 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
value = path.extname(filename);
break;
case "created":
value = new Date(fs.statSync(pathname).birthtime);
value = $tw.utils.stringifyDate(new Date(fs.statSync(pathname).birthtime));
break;
case "modified":
value = new Date(fs.statSync(pathname).mtime);
value = $tw.utils.stringifyDate(new Date(fs.statSync(pathname).mtime));
break;
}
if(fieldInfo.prefix) {