You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since you pass the Date as a string to the browser I suggest to wrap incoming dates with new Date() so it's a date object again, same other way around, if the browser sends dates to the server, although that might be solvable with Joi
The full story is this:
0. The timezone on the server is +2
In the database we have the next value 2015-04-18 00:00:00 , TIMESTAMP.
When we read the value from the database, using sequelize, we receive Sat Apr 18 2015 00:00:00 GMT+0200 (CEST) . It converts it to the date object.
When we reply, with hapi, we receive 2015-04-17T22:00:00.000Z, string. Which doesn't correspond the value in the database.
What we want to get - receive the same data in the front-end as it is stored in the database.
And, if possible - avoid the duplicate conversion in the controller/model on the back-end side. E.g. - convert the Date to simple string, so hapi would not adjust it.
Isn't that sequalize adding the GMT +2 there? And then when turning that
into Zulu that's correct so if the db stores as Zulu sequalize is doing
something wrong
The full story is this:
0. The timezone on the server is +2
In the database we have the next value 2015-04-18 00:00:00 , TIMESTAMP.
When we read the value from the database, using sequelize, we receive Sat
Apr 18 2015 00:00:00 GMT+0200 (CEST) . It converts it to the date object.
When we reply, with hapi, we receive 2015-04-17T22:00:00.000Z, string.
Which doesn't correspond the value in the database.
What we want to get - receive the same data in the front-end as it is
stored in the database.
And, if possible - avoid the duplicate conversion in the controller/model
on the back-end side. E.g. - convert the Date to simple string, so hapi
would not adjust it.
—
Reply to this email directly or view it on GitHub #2542 (comment).
hapi just called JSON.stringify() on the provided object. I don't know what console.log() does. If you want more control over the format you need to do it yourself and pass a string to reply().
Activity
PavloPoliakov commentedon May 20, 2015
I found only one line in hapijs, which looks like the one who does that convertion:
But it seems that hapi doesn't reach that point while processing the reply.
Any other thoughts?
AdriVanHoudt commentedon May 20, 2015
they are the same dates.
First one is gmt +2, so distract the 2 hours and the date is the same since date 2 is gmt +0
PavloPoliakov commentedon May 20, 2015
Well, they are the same.
But we do not expect that one string would be shaped to the other string, in the reply method.
Are there any ways to avoid it?
AdriVanHoudt commentedon May 20, 2015
Since you pass the Date as a string to the browser I suggest to wrap incoming dates with
new Date()so it's a date object again, same other way around, if the browser sends dates to the server, although that might be solvable with JoiPavloPoliakov commentedon May 20, 2015
The full story is this:
0. The timezone on the server is +2
2015-04-18 00:00:00, TIMESTAMP.Sat Apr 18 2015 00:00:00 GMT+0200 (CEST). It converts it to the date object.2015-04-17T22:00:00.000Z, string. Which doesn't correspond the value in the database.What we want to get - receive the same data in the front-end as it is stored in the database.
And, if possible - avoid the duplicate conversion in the controller/model on the back-end side. E.g. - convert the Date to simple string, so hapi would not adjust it.
AdriVanHoudt commentedon May 20, 2015
Isn't that sequalize adding the GMT +2 there? And then when turning that
into Zulu that's correct so if the db stores as Zulu sequalize is doing
something wrong
On Wed, 20 May 2015 22:15 Pavel [email protected] wrote:
PavloPoliakov commentedon May 20, 2015
yep,
It turned out that this is the sequelize issue. Which is nor bug nor feature.
Here is the solution:
sequelize/sequelize#3768 (comment)
I suppose it would help, would try tomorrow morning.
hueniverse commentedon May 21, 2015
hapi just called
JSON.stringify()on the provided object. I don't know whatconsole.log()does. If you want more control over the format you need to do it yourself and pass a string toreply().