Coder Social home page Coder Social logo

Comments (7)

jasonhinkle avatar jasonhinkle commented on June 19, 2024

Hmm interesting, thanks for finding that. I'll take a look and try to make parseDate a little more robust.

from phreeze.

jasonhinkle avatar jasonhinkle commented on June 19, 2024

Hey Arne, would you mind posting a sample date value from your app that was causing problems? I can't reproduce it here, but it's possible there's a DB setting or something perhaps internationalization setting that outputs the dates slightly differently.

Also - is datepicker input control on the edit form showing the correct date? That would be interesting because the datepicker and the table both use the same date parsing function.

thanks again

from phreeze.

ArneTR avatar ArneTR commented on June 19, 2024

Sry for the late reply.

What comes from the API, is what you expect from a MySQL Date column: "2012-08-04"

What gets retrieved by item.get() is also correct: "2012-08-04"

Then its get passed to app.parseDate(), which results in: Fri Sep 07 2012 21:48:21 GMT+0200 (CEST)

Then its gets consumed by _date, resulting in: 1347047395268

After calling .format('YYYY-MM-DD') it becomes: 2012-09-07 

So you can see, that the problem is with app.parseDate, which may be localized. I am using Chromium with an english locale in Germany. System time is GMT.

Problem persists between browsers. Not quite sure what causes this behaviour. Appending 00:00:00 however fixed it, as I said in the first post.

from phreeze.

jasonhinkle avatar jasonhinkle commented on June 19, 2024

Hmm, thanks for the reply. I'll check that out. Since it returned sept 7 (which is today) then i'm guessing the parse function somehow failed and is returning the current time in order to return a valid date object instead of null or throwing an error.

i really want to reproduce this issue before I fix it so I don't wind up masking some other bug. but i'll try to do a little research into whether Javascript date parsing works differently depending on the browser setup. It looks like having the time in there forces it to parse correctly so that's an option but I just want to make sure I'm solving the root problem and not just a symptom.

from phreeze.

jasonhinkle avatar jasonhinkle commented on June 19, 2024

OK found it & fixed in commit 449c1ee - there was a bug in app.js where when no time was provided it was throwing an exception instead of correctly appending the time. app.js is now marked as version 1.1, if you update that file then your project should work.

if you don't want to re-generate your app then you can just replace app.js with the one inside phreeze/builder/code/phreeze.backbone/scripts/app.js

from phreeze.

ArneTR avatar ArneTR commented on June 19, 2024

Well still this behavior is weird. If I have a date in my database that is "NULL" this function displays the current date (Minutes, Hours and Seconds get set to 0).

But still, I would expect 0000-00-00 00:00:00 and not 2012-09-23 00:00:00

from phreeze.

jasonhinkle avatar jasonhinkle commented on June 19, 2024

yea i'm not 100% sure what the best scenario for an illegal date in a date column would be. all zeros just gets converted to Nov 30, 1899 12:00 AM, and that's not equivalent to null. So it's probably not much better. If you wanted all zeros, though, that could be something done in the server side model code or something in "OnLoad"

I do agree that there should be some indication to the user that the date was adjusted. I don't like it when data is adjusted - even though it does write a warning to the console, the user probably won't notice that. Perhaps a validation warning could appear next to the date picker or something.

I'd say if you need to store null in date fields then it would probably require a UI that detects it and has some kind of date picker that supports null values (though i don't know of any personally).

from phreeze.

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.