jamesmortensen / archiver-for-google-keep

Scrapes notes and checklists from Google Keep™ and writes them out as JSON and markdown archive/backup files. This tool is not affiliated or endorsed by Google™. Google Keep™ is a trademark of Google.
MIT License
8 stars 0 forks source link

Error: Not a valid date string. #2

Closed mwgnr closed 1 year ago

mwgnr commented 1 year ago

In my case, there is a "narrow no-space break" instead of a "space" between the number an the AM/PM abbreviation for the lastEditedTime: 2:29 PM charCodeAt(4): 202f

It works with this regular expression: const matcher = '([A-Za-z]{3}){1} ([0-9][0-9]?)$|([A-Za-z]{3}){1} ([0-9][0-9]?){1}, ([0-9][0-9][0-9][0-9])?|[0-9]?[0-9]:[0-9][0-9]\u202f([AP]M)';

jamesmortensen commented 1 year ago

Hi @mwgnr what platform are you on? Windows, Mac, Linux, something else? I wonder if it's a platform specific thing. I built this on macOS and haven't really tried it in other environments. What do you think?

mwgnr commented 1 year ago

Sorry for the late reply. I use Linux. Unfortunately the issue still persists:

$ LANG=en_US google-chrome-stable --lang=en_US

>>> edited = "Edited yesterday, 10:52 PM"
>>> hexadecimal = []
>>> for c in edited:
...   hexadecimal.append(hex(ord(c)))
... 
>>> print(hexadecimal)
['0x45', '0x64', '0x69', '0x74', '0x65', '0x64', '0x20', '0x79', '0x65', '0x73', '0x74', '0x65', '0x72', '0x64', '0x61', '0x79', '0x2c', '0x20', '0x31', '0x30', '0x3a', '0x35', '0x32', '0x202f', '0x50', '0x4d']
jamesmortensen commented 1 year ago

I did a little more research on this. I need to handle cases for when cards say "Edited HH:MM AM/PM" and when "Edited yesterday..." because this text is written to the markdown and JSON files instead of being converted to the actual date and time.

The \u202f was an interesting find and did improve the parsing. Seems the same issue exists on macOS as well as Linux. I'll work on making those changes when I get some time, unless you want to open a pull request.

jamesmortensen commented 1 year ago

Hi @mwgnr I was able to resolve the issue thanks to your modified regular expression. The new update is published here: https://www.npmjs.com/package/archiver-for-google-keep. Hope this helps, and thank you!