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',
'file-change-yaml-lint-skipped': 'No file change detected, so YAML linting skipped',
50
+
'file-change-yaml-lint-warning': 'No file info is present, but debounce ran. Something went wrong somewhere.',
48
51
'paste-link-warning': 'aborted paste lint as the clipboard content is a link and doing so will avoid conflicts with other plugins that modify pasting.',
49
52
'see-console': 'See console for more details.',
50
53
'unknown-error': 'An unknown error occurred during linting.',
@@ -142,12 +145,16 @@ export default {
142
145
'description': 'Display the number of characters changed after linting',
143
146
},
144
147
'lint-on-file-change': {
145
-
'name': 'Lint on File Change',
148
+
'name': 'Lint on Focused File Change',
146
149
'description': 'When the a file is closed or a new file is swapped to, the previous file is linted.',
147
150
},
148
151
'display-lint-on-file-change-message': {
149
152
'name': 'Display Lint on File Change Message',
150
-
'description': 'Displays a message when `Lint on File Change` occurs',
153
+
'description': 'Displays a message when `Lint on Focused File Change` occurs',
154
+
},
155
+
'timestamp-update-on-file-contents-updated': {
156
+
'name': 'Update YAML Timestamp on File Contents Update',
157
+
'description': 'When the currently active file is modified, `YAML Timestamp` is run on the file. This should update the modified file timestamp if it is more than 5 seconds off from the current value.',
151
158
},
152
159
'folders-to-ignore': {
153
160
'name': 'Folders to ignore',
@@ -806,9 +813,13 @@ export default {
806
813
'name': 'Date Created Key',
807
814
'description': 'Which YAML key to use for creation date',
808
815
},
809
-
'force-retention-of-create-value': {
810
-
'name': 'Force Date Created Key Value Retention',
811
-
'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.',
812
823
},
813
824
'date-modified': {
814
825
'name': 'Date Modified',
@@ -904,6 +915,17 @@ export default {
904
915
'first-h1': 'First H1',
905
916
'first-h1-or-filename-if-h1-missing': 'First H1 or Filename if H1 is Missing',
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',
0 commit comments