Giter Club home page Giter Club logo

Comments (7)

mbrookes avatar mbrookes commented on August 20, 2024

Good catch - my attempt to make DateField more international-friendly by default by using ISO8601 rather than US date format has clearly backfired! 😄

In the meantime, as a workaround you can of course override formatDate, just as you would have had to anyway.

As for a fix, toLocaleDateString() seems like it ought to help, but it defaults to a US date format unless provided with a locale, so unless there's a local that produces ISO8601 style YYYY-MM-DD format, it doesn't quite solve the problem.

There's Intl.DateTimeFormat, but it isn't supported by all browsers, and pulling in a polyfill just for a default designed to be overridden seems overkill.

The best I've come up with so far is was this slightly hacky workaround:

formatDate={(date) => (new Date(date.toDateString()+" 12:00:00 +0000")).toISOString().substring(0,10)}

Could you check in the browser if that seems to solves the problem for you?

The alternative would be to just use the output of toDateString directly, which, like ISO8601, is unambiguous: "Tue Dec 01 2015", but has the disadvantage that it's in English.

from formsy-material-ui.

lukkuz avatar lukkuz commented on August 20, 2024

Yes, it works perfectly fine. Below is the transcript from the test inside my browser.

> var date = new Date(2015, 11, 1)
<- undefined
> date.toString()
<- "Tue Dec 01 2015 00:00:00 GMT+0100 (Środkowoeuropejski czas stand.)"
> date.toISOString()
<- "2015-11-30T23:00:00.000Z"
> (new Date(date.toDateString()+" 12:00:00 +0000")).toISOString().substring(0,10)
<- "2015-12-01"

from formsy-material-ui.

mbrookes avatar mbrookes commented on August 20, 2024

Thanks for checking.

Could you check against this branch? https://github.com/mbrookes/formsy-material-ui/tree/default-date

Depending on how you import NPMs, you should be able to reference the brach or the specific commit: 43f4955

from formsy-material-ui.

lukkuz avatar lukkuz commented on August 20, 2024

I've tried checking against this commit but things seem to be broken. My build fails with a message:

ERROR in ./src/components/Comment/CommentDialog.js
Module not found: Error: Cannot resolve module 'formsy-material-ui' in /home/osboxes/devel/tmp-web-client/src/components/Comment
...skipped some lines...
resolve file
/home/osboxes/devel/tmp-web-client/node_modules/formsy-material-ui/index.js doesn't exist

I'm using ES6 syntax in my code.

My understanding is that somehow package.json file was also edited and "main": "lib/index.js" was replaced with "main": "index.js" and there is no such file in main dir.

I've tried to find a commit that did this thing but wasn't successful. It seems that version 0.3.2 was released from version than had not been pushed into main repo. I say that because I can't see "gitHead": "e43fd8fec546c68766495e154bf3d81393f38dd7" (package.json:53 from [email protected]) in repo which is strange. No such commit.

from formsy-material-ui.

mbrookes avatar mbrookes commented on August 20, 2024

You're right - it looks like I published from the separate-components branch instead of merging and publishing from master. Rather than try to reconcile now, I've updated the default-date branch with what should be a working package.json (and a transpiled version of FormsyDate).

If it looks okay for you, then I'll try to clean up my branch / commit foobar and merge this with master and publish.

from formsy-material-ui.

lukkuz avatar lukkuz commented on August 20, 2024

Yes, default-date works as expected now. Thanks for prompt support.

from formsy-material-ui.

mbrookes avatar mbrookes commented on August 20, 2024

0.3.3 published to NPM. Thanks for the report.

from formsy-material-ui.

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.