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

Date type filed saving problems #120

Closed
daddybh opened this issue Aug 27, 2015 · 5 comments
Closed

Date type filed saving problems #120

daddybh opened this issue Aug 27, 2015 · 5 comments

Comments

@daddybh
Copy link

daddybh commented Aug 27, 2015

Hi, I am wondering there is any way not to convert Date filed to UTC format?

Because there are some sql query in my system, and it would come to a inconsistency of the timezone.

I tried to add a timezone parameter in datasource configuration, but it didnot take any affect.

@xiangmeng4geo
Copy link

I met the same problem.
I found the code at
node_modules/loopback-connector-mysql/lib/mysql.js
line 253: return val.getFullUTCYear()......
line 353:val = new Date(val.toString().replace(/GMT.*$/, 'GMT'));
I think it is a problem to handle time zone like this,so I remove the UTC at line 253 and comment the line 353 .

@daddybh
Copy link
Author

daddybh commented Nov 6, 2015

@xiangmeng4geo you can put a "dateStrings": true in you datasource.json file. It will solve the problem without change the source code.

@xiangmeng4geo
Copy link

@daddybh Oh,Thank you very much.

@bbito
Copy link
Contributor

bbito commented Feb 17, 2016

Another big thanks to @daddybh!
After going over LB's MySQL Connector Docs: https://docs.strongloop.com/display/public/LB/MySQL+connector , I didn't find anything about a dateStrings option this until finding this issue and taking the next step to the node-mysql github where the dateStrings option is described: https://github.com/felixge/node-mysql#connection-options as follows:

dateStrings: Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects. (Default: false)

bbito added a commit to bbito/node-mysql that referenced this issue Mar 7, 2016
Adding checks to allow true OR "DATE" as dateStrings values "DATE" should only effect DATE fields whereas true retains original behavior, effecting DATE, DATETIME and TIMESTAMP fields. See: mysqljs#605 , loopbackio/loopback-connector-mysql#120 , loopbackio/loopback-connector-mysql#149
@jannyHou
Copy link
Contributor

@xiangmeng4geo @daddybh As @bbito mentioned, this issue is a same one as #149
Shall we close this one and keep our discussion under issue#149? More people are involved there, easier for us to track the appropriate solutions. Thanks.

@jannyHou jannyHou self-assigned this Jul 29, 2016
@jannyHou jannyHou removed their assignment Jul 29, 2016
bbito added a commit to bbito/node-mysql that referenced this issue Sep 29, 2016
Adding checks to allow true OR "DATE" as dateStrings values "DATE" should only effect DATE fields whereas true retains original behavior, effecting DATE, DATETIME and TIMESTAMP fields. See: mysqljs#605 , loopbackio/loopback-connector-mysql#120 , loopbackio/loopback-connector-mysql#149
bbito added a commit to bbito/node-mysql that referenced this issue Sep 30, 2016
Add 'date' as dateStrings value option. The connection option dateStrings: 'date' will only affect DATE fields whereas any truthy value (except 'date') retains original behavior, effecting DATE, DATETIME and TIMESTAMP fields. See: mysqljs#605 , loopbackio/loopback-connector-mysql#120 , loopbackio/loopback-connector-mysql#149
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

No branches or pull requests

4 participants