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

convert date for db adapters #153

Closed
eddyystop opened this issue Apr 19, 2017 · 3 comments
Closed

convert date for db adapters #153

eddyystop opened this issue Apr 19, 2017 · 3 comments

Comments

@eddyystop
Copy link
Collaborator

eddyystop commented Apr 19, 2017

function convertDate(fieldName) {
  return function(hook) {
    const prop = hook.data && hook.data[fieldName];

    if(prop) {
      hook.data[fieldName] = Date().toISOString().slice(0, 19).replace('T', ' ');
    }
    
    return Promise.resolve(hook);
  }  
}
@ekryski
Copy link
Member

ekryski commented May 4, 2017

Which DB doesn't take ISO formatted dates?

@eddyystop mentioned that this came from an issue from a community member in Slack.

To me, this seems like an edge case with their system. I’ve never run into that across PG, NeDB, SQLite, and Mongo so part of me feels like that is probably just a custom hook someone should be writing if they need it and it doesn't belong as a common hook.

Personally, I'd say we close this and revisit if it comes up frequently. It's so easy/cheap to write hooks that we really should only tackle the common ones that people require. We can't write one for every possible scenario. 😄

@ekryski ekryski closed this as completed May 4, 2017
@ekryski ekryski reopened this May 10, 2017
@ekryski ekryski closed this as completed May 10, 2017
@arlair
Copy link

arlair commented Oct 4, 2017

I came across this and it seems MySQL 5.6 introduced a STRICT_TRANS_TABLES sql_mode that only allows MySQL formatted dates and not ISO formatted.

Options seem to be disabling STRICT_TRANS_TABLES, or formatting dates in a manner like the code above.

See here for an example: https://dba.stackexchange.com/questions/48704/mysql-5-6-datetime-incorrect-datetime-value-2013-08-25t1700000000-with-er

@eddyystop
Copy link
Collaborator Author

Consolidated with #347

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants