Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

jrnl import date shifted #69

Closed
jrmillerUSA opened this issue Apr 1, 2020 · 7 comments
Closed

jrnl import date shifted #69

jrmillerUSA opened this issue Apr 1, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@jrmillerUSA
Copy link

jrmillerUSA commented Apr 1, 2020

When using the Import jrnl function, it looks like the date is skewed by one day. Mini Diary imports the date for say 3/29 as 3/28.

Below is the jrnl export file contents.

{
  "entries": [
    {
      "body": "This is March 29th", 
      "date": "2020-03-29", 
      "starred": false, 
      "time": "09:00", 
      "title": "Default"
    }
  ], 
  "tags": {}
}
@samuelmeuli
Copy link
Owner

It's working as expected for me. Are the tests passing on your machine?

@samuelmeuli samuelmeuli added the bug Something isn't working label Apr 5, 2020
@jrmillerUSA
Copy link
Author

Sorry I'm a noob with node/electron, and I'm not sure how to run the tests. I'm also not able to successfully run 'yarn start' since I don't have a proper X session and using WSL. I'll try to find another platform to build the app with in the meantime.

Let me know if there's an easier way to run the test or if there's other info I can provide.

Thanks for looking into it since I'd really like to use your app!

@CosimoG
Copy link
Contributor

CosimoG commented Apr 5, 2020

I think that the issue is related to how the Date object works.
If a YYYY-MM-DD string is passed to the object constructor, it will be parsed with the GMT time zone,
but when the method toString() is called, it will return the timestamp in the local time zone, causing the shift.

> d = new Date("2019-03-29")
2019-03-29T00:00:00.000Z
> d.toString()
Thu Mar 28 2019 18:00:00 GMT-0600 (GMT-06:00)

If a YYYY-MM-DD HH:mm:ss string is passed to the constructor, it will be parsed with the local time zone
and when the method toString() is called, it will return the correct timestamp.

> d = new Date("2019-03-29 00:00:00")
2019-03-29T06:00:00.000Z
> d.toString()
Fri Mar 29 2019 00:00:00 GMT-0600 (GMT-06:00)

Currently the parseJrnlJson method parses only the date field ignoring the time field in the exported jrnl file.
A solution could be parsing the entry date using both the date and the time fields.
The only concern I have about this solution is that the jrnl app doesn't record any time zone info in the exported file and this could be a problem when the jrnl diary is imported in a time zone
different from the one it was exported.

@samuelmeuli
Copy link
Owner

Interesting, I wasn't aware of that. Thanks for the detailed explanation, @CosimoG!

If I understand this correctly, calling toUTCString instead of toString should fix it then. This means Mini Diary will parse and store data in GMT, which should simplify things.

@samuelmeuli
Copy link
Owner

@jrmillerUSA Has v3.1.0 fixed this for you?

@jrmillerUSA
Copy link
Author

@jrmillerUSA Has v3.1.0 fixed this for you?

I haven't been able to test properly as a result of the calendar bugs (I can't actually get to my entry). Will confirm once those are fixed. Thanks for the quick fix!

@jrmillerUSA
Copy link
Author

Confirmed this is now addressed. Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants