zhughes3 / kruonis

A timeline platform.
https://timelines.dev
0 stars 0 forks source link

Debug date input issue #11

Open zhughes3 opened 4 years ago

zhughes3 commented 4 years ago

I am finding that when I input a date, it shows up on screen as the day before.

For example, I'll input "05-15-1991". It gets saved to the DB as: "1991-05-15 00:00:00" but renders on the screen as: May 14th, 1991.

L-u-n-a commented 4 years ago

I'm not getting this bug, and I can't seem to recreate it. It could have something to do with EU/US dates, or maybe it's in the browser?

Browsers I tested this on Firefox, Chrome, Chromium,

Date formats I tested dd/mm/yyyy yyyy/mm/dd mm/dd/yyyy

Could you tell me if anything is different in the way you tested it?

zhughes3 commented 4 years ago

I input this event with a bunch of data. The date I inputted is 06/01/2003. Note how the date rendered is the day before.

https://imgur.com/KWbZsvS

I'm still not sure why.

The timestamp saved in the database is '2003-06-01 00:00:00'.

The timestamp that the frontend javascript receives is '2003-06-01T00:00:00Z'.

L-u-n-a commented 4 years ago

When I try to input the same date it doesn't do that, so It's hard to debug.

Ill try the following fix: When you input a day ill add 1 hour to that day. so 2003-06-01 00:00:00 will become 2003-06-01 01:00:00

zhughes3 commented 4 years ago

I like the "hack" you mention above. Since we don't ever render the time, only the date, on the frontend. This should work fine.

Honestly, I think I made a mistake on saving "datetime" in postgresql. I should have saved just the date.

I don't think its worth a refactor as of yet though. Your solution should get us working more as expected.