1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Resolves #9683: Frontmatter importer: Support Notesnook-style timestamps (#9684)

This commit is contained in:
Henry Heino 2024-01-08 03:59:44 -08:00 committed by GitHub
parent 94e3582bb8
commit 32e76d7988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,9 @@
---
title: "Frontmatter test"
created_at: 01-01-2024 01:23 AM
updated_at: 02-01-2024 04:56 AM
---
# Frontmatter test
A test note with frontmatter.

View File

@ -140,6 +140,13 @@ describe('InteropService_Importer_Md_frontmatter: importMetadata', () => {
expect(note.title).toBe('Distill for R Markdown'); expect(note.title).toBe('Distill for R Markdown');
expect(note.author).toBe('JJ Allaire'); expect(note.author).toBe('JJ Allaire');
}); });
it('should import Notesnook files with created and update timestamps', async () => {
const note = await importTestFile('notesnook_updated_created.md');
expect(note.title).toBe('Frontmatter test');
expect(note.user_created_time).toBe(Date.parse('2024-01-01T01:23:00.000'));
expect(note.user_updated_time).toBe(Date.parse('2024-01-02T04:56:00.000'));
});
it('should handle date formats with timezone information', async () => { it('should handle date formats with timezone information', async () => {
const note = await importTestFile('utc.md'); const note = await importTestFile('utc.md');

View File

@ -111,6 +111,9 @@ export default class InteropService_Importer_Md_frontmatter extends InteropServi
metadata['user_created_time'] = time.anythingToMs(md['created'], Date.now()); metadata['user_created_time'] = time.anythingToMs(md['created'], Date.now());
} else if ('date' in md) { } else if ('date' in md) {
metadata['user_created_time'] = time.anythingToMs(md['date'], Date.now()); metadata['user_created_time'] = time.anythingToMs(md['date'], Date.now());
} else if ('created_at' in md) {
// Add support for Notesnook
metadata['user_created_time'] = time.anythingToMs(md['created_at'], Date.now());
} }
if ('updated' in md) { if ('updated' in md) {
@ -120,6 +123,9 @@ export default class InteropService_Importer_Md_frontmatter extends InteropServi
metadata['user_updated_time'] = time.anythingToMs(md['lastmod'], Date.now()); metadata['user_updated_time'] = time.anythingToMs(md['lastmod'], Date.now());
} else if ('date' in md) { } else if ('date' in md) {
metadata['user_updated_time'] = time.anythingToMs(md['date'], Date.now()); metadata['user_updated_time'] = time.anythingToMs(md['date'], Date.now());
} else if ('updated_at' in md) {
// Notesnook
metadata['user_updated_time'] = time.anythingToMs(md['updated_at'], Date.now());
} }
if ('latitude' in md) { metadata['latitude'] = md['latitude']; } if ('latitude' in md) { metadata['latitude'] = md['latitude']; }