Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'utcDateCreated' to patch_note() #42

Merged
merged 2 commits into from
Jun 20, 2024
Merged

Conversation

maphew
Copy link
Contributor

@maphew maphew commented Jun 19, 2024

spawned from https://github.com/orgs/TriliumNext/discussions/169, the most significant part being:

zadam: I've added the possibility to specify dateCreated and utcDateCreated to the ETAPI. The modification date is still generated automatically. -- from zadam/trilium#4199

mhw-at-yg and others added 2 commits June 12, 2024 14:06
raw date:   03.08.2011
Content date: 2011-03-08 00:00:00
Target noteId: 9Oy2w4oi3IhN
Content date: 2011-03-08 00:00:00
Patch utcDateCreated: {'status': 400, 'code': 'PROPERTY_VALIDATION_ERROR', 'message': "Validation failed on property 'utcDateCreated': Invalid UTC date time format in '2011-03-08 00:00:00'. Correct format shoud follow example: '2023-08-21 23:38:51.110Z'."}
@Nriver Nriver merged commit ba966ca into Nriver:main Jun 20, 2024
@Nriver
Copy link
Owner

Nriver commented Jun 20, 2024

Thank you!

@maphew
Copy link
Contributor Author

maphew commented Jun 20, 2024

You're welcome. It was one of those "size of the code does not reflect the mental effort at all" exercises! Date handling is mind bending.

@maphew
Copy link
Contributor Author

maphew commented Jun 20, 2024

I had intended to ignore also adding dateCreated since it's generally more reliable for me to always use UTC, however it turns out that changing utcDateCreated leaves the original dateCreated untouched, which is not desireable because a) the interface reports the latter, and b) having 2 entirely diff datestamps in attributes is surely going to lead to trouble.

Patch utcDateCreated: {'noteId': 'W4waSxjx1haB', 'isProtected': False, 'title': 'date testing', ....snip...
'dateCreated': '2024-06-14 15:51:05.844-0700', 'dateModified': '2024-06-20 04:27:27.232+0000',
'utcDateCreated': '2011-03-08 07:00:00.083Z', 'utcDateModified': '2024-06-20 04:27:27.232Z', '...snip...

image

@alglez
Copy link

alglez commented Jun 20, 2024

Funny enough i was using utcDateCreated right now for some notes that still i need to import from joplin and I found the same bug (well not sure if it's intended since you need an extra check) that i was going to report to trilium.

In trilium when you set utcDateCreated, dateCreated is not changed, so you need to set both at the same time.

For example just doing curl from the terminal:


curl -X POST -H "Authorization":"AAA" -H "Content-Type: application/json" -d '{"title" : "title", "content":"content", "parentNoteId": "BBB", "type": "text", "dateCreated": "2023-08-21 23:38:51.110+0200" }' 'http://localhost:37840/etapi/create-note'

{"note":{"noteId":"DDD","isProtected":false,"title":"title","type":"text","mime":"text/html","blobId":"CCC","dateCreated":"2023-08-21 23:38:51.110+0200","dateModified":"2024-06-20 18:00:26.111+0100","utcDateCreated":"2024-06-20 17:00:26.111Z","utcDateModified":"2024-06-20 17:00:26.111Z","parentNoteIds":["BBB"],"childNoteIds":[],"parentBranchIds":["FFF"],"childBranchIds":[],"attributes":[]},"branch":{"branchId":"EEE","noteId":"DDD","parentNoteId":"BBB","prefix":null,"notePosition":50,"isExpanded":false,"utcDateModified":"2024-06-20 17:00:26.111Z"}}⏎  

so as utcDateCreated and dateCreated are different if you only specify one.

@maphew
Copy link
Contributor Author

maphew commented Jun 29, 2024

PR #43 sets both dateCreated and utcDateCreated regardless of which one was passed to ea.patch_note()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants