You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: __tests__/yaml-timestamp.test.ts
+123-7Lines changed: 123 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -63,12 +63,12 @@ ruleTest({
63
63
format: 'dddd, MMMM Do YYYY, h:mm a ',
64
64
currentTime: moment('Thursday, January 2nd 2020, 12:01 am','dddd, MMMM Do YYYY, h:mm a'),
65
65
alreadyModified: false,
66
-
forceRetentionOfCreatedValue: false,
66
+
dateCreatedSourceOfTruth: 'frontmatter',
67
67
fileModifiedTime: '2020-01-02T00:00:00-00',
68
68
},
69
69
},
70
70
{
71
-
testName: 'When the date format changes and `forceRetentionOfCreatedValue = true`, date created value is based on the one in the YAML frontmatter.',
71
+
testName: 'When the date format changes and `dateCreatedSourceOfTruth = frontmatter`, date created value is based on the one in the YAML frontmatter.',
72
72
before: dedent`
73
73
---
74
74
created: Wednesday, January 1st 2020, 12:00:00 am
@@ -82,7 +82,7 @@ ruleTest({
82
82
options: {
83
83
dateModified: false,
84
84
dateCreatedKey: 'created',
85
-
forceRetentionOfCreatedValue: true,
85
+
dateCreatedSourceOfTruth: 'frontmatter',
86
86
format: 'YYYY, h:mm:ss a',
87
87
locale: 'en',
88
88
},
@@ -359,7 +359,7 @@ ruleTest({
359
359
},
360
360
},
361
361
{// accounts for https://github.com/platers/obsidian-linter/issues/745
362
-
testName: 'When no changes are made, and force retention of creation date is active, do not update date modified when no change in modification time has been made',
362
+
testName: 'When no changes are made, and frontmatter is the source of truth, do not update date modified when no change in modification time has been made',
363
363
before: dedent`
364
364
---
365
365
tag: tag1
@@ -383,11 +383,11 @@ ruleTest({
383
383
fileModifiedTime: '2020-02-04T18:00:00-00:00',
384
384
currentTime: moment('Tuesday, February 4th 2020, 6:00:07 pm','dddd, MMMM Do YYYY, h:mm:ss a'),
385
385
alreadyModified: false,
386
-
forceRetentionOfCreatedValue: true,
386
+
dateCreatedSourceOfTruth: 'frontmatter',
387
387
},
388
388
},
389
389
{
390
-
testName: 'When creation date exists and force retention of created date and convert to UTC are true, creation date should remain unchanged',
390
+
testName: 'When creation date exists and frontmatter is the source of truth and convert to UTC are true, creation date should remain unchanged',
391
391
before: dedent`
392
392
---
393
393
created: 2019-12-31T14:00:00+00:00
@@ -405,7 +405,7 @@ ruleTest({
405
405
dateModified: false,
406
406
fileCreatedTime: '2020-01-01T09:00:00-05:00',// 9 AM Eastern Standard Time
407
407
currentTime: moment('2020-01-01T21:00:05-05:00','YYYY-MM-DDTHH:mm:ssZ'),// 9:00:05 PM EST, same day
408
-
forceRetentionOfCreatedValue: true,
408
+
dateCreatedSourceOfTruth: 'frontmatter',
409
409
convertToUTC: true,
410
410
},
411
411
},
@@ -435,5 +435,121 @@ ruleTest({
435
435
convertToUTC: true,
436
436
},
437
437
},
438
+
{
439
+
testName: 'When changes are made prior to the YAML timestamp rule and user and Linter edits are the source of truth, update date modified',
440
+
before: dedent`
441
+
---
442
+
tag: tag1
443
+
modified: Tuesday, February 4th 2020, 6:00:00 pm
444
+
created: Wednesday, January 1st 2020, 12:00:00 am
445
+
location: "path"
446
+
---
447
+
`,
448
+
after: dedent`
449
+
---
450
+
tag: tag1
451
+
modified: Tuesday, February 4th 2020, 6:00:07 pm
452
+
created: Wednesday, January 1st 2020, 12:00:00 am
453
+
location: "path"
454
+
---
455
+
`,
456
+
options: {
457
+
dateCreatedKey: 'created',
458
+
dateModifiedKey: 'modified',
459
+
fileCreatedTime: '2020-01-01T00:00:00-00:00',
460
+
fileModifiedTime: '2020-02-04T18:00:00-00:00',
461
+
currentTime: moment('Tuesday, February 4th 2020, 6:00:07 pm','dddd, MMMM Do YYYY, h:mm:ss a'),
462
+
alreadyModified: true,
463
+
dateCreatedSourceOfTruth: 'frontmatter',
464
+
dateModifiedSourceOfTruth: 'user or Linter edits',
465
+
},
466
+
},
467
+
{
468
+
testName: 'When no changes are made prior to the YAML timestamp rule, the created date format is different from the current format in settings, and user and Linter edits are the source of truth, update date modified',
469
+
before: dedent`
470
+
---
471
+
tag: tag1
472
+
modified: Tuesday, February 4th 2020, 6:00:00 pm
473
+
created: Wednesday, January 1st 2020, 12:00 am
474
+
location: "path"
475
+
---
476
+
`,
477
+
after: dedent`
478
+
---
479
+
tag: tag1
480
+
modified: Tuesday, February 4th 2020, 6:00:07 pm
481
+
created: Wednesday, January 1st 2020, 12:00:00 am
482
+
location: "path"
483
+
---
484
+
`,
485
+
options: {
486
+
dateCreatedKey: 'created',
487
+
dateModifiedKey: 'modified',
488
+
fileCreatedTime: '2020-01-01T00:00:00-00:00',
489
+
fileModifiedTime: '2020-02-04T18:00:00-00:00',
490
+
currentTime: moment('Tuesday, February 4th 2020, 6:00:07 pm','dddd, MMMM Do YYYY, h:mm:ss a'),
491
+
alreadyModified: false,
492
+
dateCreatedSourceOfTruth: 'frontmatter',
493
+
dateModifiedSourceOfTruth: 'user or Linter edits',
494
+
},
495
+
},
496
+
{
497
+
testName: 'When no changes are made prior to the YAML timestamp rule, the modified date format is different from the current format in settings, and user and Linter edits are the source of truth, update date modified',
498
+
before: dedent`
499
+
---
500
+
tag: tag1
501
+
modified: Tuesday, February 4th 2020, 6:00 pm
502
+
created: Wednesday, January 1st 2020, 12:00:00 am
503
+
location: "path"
504
+
---
505
+
`,
506
+
after: dedent`
507
+
---
508
+
tag: tag1
509
+
modified: Tuesday, February 4th 2020, 6:00:07 pm
510
+
created: Wednesday, January 1st 2020, 12:00:00 am
511
+
location: "path"
512
+
---
513
+
`,
514
+
options: {
515
+
dateCreatedKey: 'created',
516
+
dateModifiedKey: 'modified',
517
+
fileCreatedTime: '2020-01-01T00:00:00-00:00',
518
+
fileModifiedTime: '2020-02-04T18:00:00-00:00',
519
+
currentTime: moment('Tuesday, February 4th 2020, 6:00:07 pm','dddd, MMMM Do YYYY, h:mm:ss a'),
520
+
alreadyModified: false,
521
+
dateCreatedSourceOfTruth: 'frontmatter',
522
+
dateModifiedSourceOfTruth: 'user or Linter edits',
523
+
},
524
+
},
525
+
{
526
+
testName: 'When no changes are made prior to the YAML timestamp rule, the file system date modified is more than 5 seconds different from the date modified, and user and Linter edits are the source of truth, do not update date modified',
527
+
before: dedent`
528
+
---
529
+
tag: tag1
530
+
modified: Tuesday, February 4th 2020, 6:00:00 pm
531
+
created: Wednesday, January 1st 2020, 12:00:00 am
532
+
location: "path"
533
+
---
534
+
`,
535
+
after: dedent`
536
+
---
537
+
tag: tag1
538
+
modified: Tuesday, February 4th 2020, 6:00:00 pm
539
+
created: Wednesday, January 1st 2020, 12:00:00 am
540
+
location: "path"
541
+
---
542
+
`,
543
+
options: {
544
+
dateCreatedKey: 'created',
545
+
dateModifiedKey: 'modified',
546
+
fileCreatedTime: '2020-01-01T00:00:00-00:00',
547
+
fileModifiedTime: '2020-02-05T18:00:00-00:00',
548
+
currentTime: moment('Tuesday, February 5th 2020, 6:00:07 pm','dddd, MMMM Do YYYY, h:mm:ss a'),
549
+
alreadyModified: false,
550
+
dateCreatedSourceOfTruth: 'frontmatter',
551
+
dateModifiedSourceOfTruth: 'user or Linter edits',
Copy file name to clipboardExpand all lines: src/lang/locale/de.ts
-4Lines changed: 0 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -690,10 +690,6 @@ export default {
690
690
'name': 'Schlüssel für das Erstellungsdatum',
691
691
'description': 'Der YAML-Schlüssel, der für das Erstellungsdatum verwendet werden soll',
692
692
},
693
-
'force-retention-of-create-value': {
694
-
'name': 'Erzwinge die Beibehaltung des Schlüsselwertes für das Erstellungsdatum',
695
-
'description': 'Verwendet den Wert im YAML-Frontmatter für das Erstellungsdatum anstelle den Dateimetadaten, was nützlich ist, um zu verhindern, dass Änderungen an Dateimetadaten dazu führen, dass der Wert in einen anderen Wert geändert wird.',
696
-
},
697
693
'date-modified': {
698
694
'name': 'Änderungsdatum',
699
695
'description': 'Geben Sie das Datum ein, an dem die Datei zuletzt geändert wurde',
Copy file name to clipboardExpand all lines: src/lang/locale/en.ts
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -813,9 +813,13 @@ export default {
813
813
'name': 'Date Created Key',
814
814
'description': 'Which YAML key to use for creation date',
815
815
},
816
-
'force-retention-of-create-value': {
817
-
'name': 'Force Date Created Key Value Retention',
818
-
'description': 'Reuses the value in the YAML frontmatter for date created instead of the file metadata which is useful for preventing file metadata changes from causing the value to change to a different value.',
816
+
'date-created-source-of-truth': {
817
+
'name': 'Date Created Source of Truth',
818
+
'description': 'Specifies where to get the date created value from if it is already present in the frontmatter.',
819
+
},
820
+
'date-modified-source-of-truth': {
821
+
'name': 'Date Modified Source of Truth',
822
+
'description': 'Specifies what way should be used to determine when the date modified should be updated if it is already present in the frontmatter.',
Copy file name to clipboardExpand all lines: src/lang/locale/es.ts
-4Lines changed: 0 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -606,10 +606,6 @@ export default {
606
606
'name': 'Clave de fecha de creación',
607
607
'description': 'La clave de YAML para usar para la fecha de creación',
608
608
},
609
-
'force-retention-of-create-value': {
610
-
'name': 'Forzar la fecha de creación de la retención del valor clave',
611
-
'description': 'Reutiliza el valor en el frontmatter del YAML para la fecha de creación en lugar de los metadatos del archivo, lo que es útil para evitar que los cambios en los metadatos del archivo provoquen que el valor cambie a un valor diferente.',
612
-
},
613
609
'date-modified': {
614
610
'name': 'Fecha modificada',
615
611
'description': 'Inserte la fecha en que se modificó el archivo por última vez',
Copy file name to clipboardExpand all lines: src/lang/locale/tr.ts
-4Lines changed: 0 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -686,10 +686,6 @@ export default {
686
686
'name': 'Oluşturma Tarihi Anahtarı',
687
687
'description': 'Oluşturma tarihi için hangi YAML anahtarını kullanacağı',
688
688
},
689
-
'force-retention-of-create-value': {
690
-
'name': 'Oluşturma Tarihi Anahtar Değerinin Korunmasını Zorla',
691
-
'description': 'Dosya metadatası yerine YAML ön maddesindeki tarihi yeniden kullanır, bu da dosya metadatasındaki değişikliklerin değerin farklı bir değere değişmesine neden olmasını önler.',
692
-
},
693
689
'date-modified': {
694
690
'name': 'Değiştirme Tarihi',
695
691
'description': 'Dosyanın son değiştirildiği tarihi ekler',
description: 'The file system date modified value is used to set the value of date modified in the frontmatter',
439
+
},
440
+
{
441
+
value: 'user or Linter edits',
442
+
description: 'When a value is present in the frontmatter for date modified, date modified is kept as is unless the user or the Linter makes a change to the file',
0 commit comments