Giter Site home page Giter Site logo

Comments (8)

cliedelt avatar cliedelt commented on April 28, 2024 1

This is still important. Any updates?

from bookshelf.

tgriesser avatar tgriesser commented on April 28, 2024

Yeah, I'm working on a typecasting module & hooks that will help with this. In the meantime you can filter this stuff with a custom model.format method.

from bookshelf.

amitava82 avatar amitava82 commented on April 28, 2024

Excellent! Yes I was planning of using format and parse for now. Looking forward to it and validation.

from bookshelf.

sudhirvkumar avatar sudhirvkumar commented on April 28, 2024

Any update on this is appreciated.

from bookshelf.

johanneslumpe avatar johanneslumpe commented on April 28, 2024

@tgriesser Why are we even using datetime and not timestamp ? Wouldn't the whole issue just vaporize, if we used a timestamp type for those fields? (which then could just receive the value from either new Date().getTime() or Date.now())

Reading the date back would of course use the timezone of the server, but would yield the correct time, in contrast to saving a string into a datetime field, which has been converted to UTC earlier. Like this:

var d = new Date(1389166613497) // just passing in the timestamp for a consistent example
var dTS = d.getTime() // => 1389166613497
var dString = d.toJSON() // => "2014-01-08T07:36:53.497Z"

If we were able to save dString into the database everything would be fine, since recreating a date from it would yield the correct result, like this:

// the date will be correctly converted to the local timezone
var dateLater = new Date(dString); 

But since we only have a string representation like 2014-01-08 07:36:53, recreating the date from the database will result in this:

// will specify the date in the local timezone, even though it's UTC
var dateFromDB = new Date("2014-01-08 07:36:53");
dateFromDB.toJSON() // => "2014-01-08T05:36:53.000Z" - oops

Apart from hitting a bug in 2038 - is there anything that makes this not feasible?

from bookshelf.

johanneslumpe avatar johanneslumpe commented on April 28, 2024

gotta bump this one again @tgriesser ;) Any opinion about this? Or any progress which hasn't surfaced yet?

from bookshelf.

SkylerRogers avatar SkylerRogers commented on April 28, 2024

@tgriesser - how safe/reliable is it to handle this issue via the knex config (assuming you desire everything to be stored in UTC)?

For example something like this:

module.exports = {
  development: {
    client: 'mysql',
    connection: {
      host: 'localhost',
      user: 'root',
      password: '',
      database: 'my_database',
      timezone: 'UTC'
    }
  }
}

from bookshelf.

crunchtime-ali avatar crunchtime-ali commented on April 28, 2024

The project leadership of Bookshelf recently changed. In an effort to advance the project we close all issues older than one year.

If you think this issue needs to be re-evaluated please post a comment on why this is still important and we will re-open it.

We also started an open discussion about the future of Bookshelf.js here #1600. Feel free to drop by and give us your opinion.
Let's make Bookshelf great again

from bookshelf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.