Git Product home page Git Product logo

react-bootstrap-date-picker's Introduction

React-Bootstrap based date picker.

NPM Version Circle CI Coverage Status Dependency Status NPM Downloads

See the demo at pushtell.github.io/react-bootstrap-date-picker.

Demo

Please โ˜… on GitHub!

Using this module in production? We'd love to hear about it.

Table of Contents

Installation

react-bootstrap-date-picker is compatible with React 0.14.x and 0.15.x.

npm install react-bootstrap-date-picker

Usage

var DatePicker = require("react-bootstrap-date-picker");

var App = React.createClass({
  getInitialState: function(){
    var value = new Date().toISOString();
    return {
      value: value
    }
  },
  handleChange: function(value, formattedValue) {
    this.setState({
      value: value, // ISO String, ex: "2016-11-19T12:00:00.000Z"
      formattedValue: formattedValue // Formatted String, ex: "11/19/2016"
    });
  },
  componentDidUpdate: function(){
    // Access ISO String and formatted values from the DOM.
    var hiddenInputElement = document.getElementById("example-datepicker");
    console.log(hiddenInputElement.value); // ISO String, ex: "2016-11-19T12:00:00.000Z"
    console.log(hiddenInputElement.getAttribute('data-formattedvalue')) // Formatted String, ex: "11/19/2016"
  },
  render: function(){
    return <FormGroup>
      <ControlLabel>Label</ControlLabel>
      <DatePicker id="example-datepicker" value={this.state.value} onChange={this.handleChange} />
      <HelpBlock>Help</HelpBlock>
    </FormGroup>;
  }
});

API Reference

<DatePicker />

DatePicker component. Renders as a React-Bootstrap InputGroup.

InputGroup properties are passed through to the input group.

  • Properties:

    • value - ISO date string representing the current value.
      • Optional
      • Type: string
      • Example: "2016-05-19T12:00:00.000Z"
    • defaultValue - ISO date string representing the default value. Cannot be set with 'value'.
      • Optional
      • Type: string
      • Example: "2016-05-19T12:00:00.000Z"
    • minDate - ISO date string to set the lowest allowable date value.
      • Optional
      • Type: string
      • Example: "2016-05-19T12:00:00.000Z"
    • maxDate - ISO date string to set the highest allowable date value.
      • Optional
      • Type: string
      • Example: "2016-05-19T12:00:00.000Z"
    • style - Style object passed to the FormControl input element.
      • Optional
      • Type: object
      • Example: {width: "100%"}
    • className - Class name passed to the FormControl input element.
      • Optional
      • Type: string
      • Example: example-class
    • autoComplete - autoComplete attribute passed to the FormControl input element.
      • Optional
      • Type: string
      • Example: off
    • autoFocus - Whether or not component starts with focus.
      • Optional
      • Type: bool
      • Example: false
    • disabled - Whether or not component is disabled.
      • Optional
      • Type: bool
      • Example: false
    • onChange - Focus callback function.
      • Optional
      • Type: function
      • Callback Arguments:
        • value - ISO date string representing the selected value.
          • Type: String
          • Example: "2016-05-19T12:00:00.000Z"
        • formattedValue - String representing the formatted value as defined by the dateFormat property.
          • Type: String
          • Example: "05/19/2016"
    • onFocus - Focus callback function.
      • Optional
      • Type: function
      • Callback Arguments:
        • event - Focus event.
          • Type: Event
    • onBlur - Blur callback function.
      • Optional
      • Type: function
      • Callback Arguments:
        • event - Blur event.
          • Type: Event
    • dateFormat - Date format. Any combination of DD, MM, YYYY and separator.
      • Optional
      • Type: string
      • Examples: "MM/DD/YYYY", "YYYY/MM/DD", "MM-DD-YYYY", or "DD MM YYYY"
    • clearButtonElement - Character or component to use for the clear button.
      • Optional
      • Type: string or ReactClass
      • Example: "ร—"
    • showClearButton - Toggles the visibility of the clearButton
      • Optional
      • Type: bool
      • Example: false
    • onClear - Defines what happens when clear button is clicked.
      • Optional
      • Type: function
    • previousButtonElement - Character or component to use for the calendar's previous button.
      • Optional
      • Type: string or ReactClass
      • Example: "<"
    • nextButtonElement - Character or component to use for the calendar's next button.
      • Optional
      • Type: string or ReactClass
      • Example: ">"
    • cellPadding - CSS padding value for calendar date cells.
      • Optional
      • Type: string
      • Example: "2px"
    • dayLabels - Array of day names to use in the calendar. Starting on Sunday.
      • Optional
      • Type: array
      • Example: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
    • monthLabels - Array of month names to use in the calendar.
      • Optional
      • Type: array
      • Example: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
    • calendarPlacement - Overlay placement for the popover calendar.
      • Optional
      • Type: string or function
      • Example: "top"
    • calendarContainer - Overlay container for the popover calendar. When placing the date-picker in a scrolling container, set this prop to some ancestor of the scrolling container.
      • Optional
      • Type: A DOM element or a component
      • Example: document.body
    • weekStartsOnMonday - OBSOLETE use weekStartsOn
    • weekStartsOn - Makes the calendar's week to start on a specified day. 0 = Sunday, 1 = Monday, etc.
      • Optional
      • Type: number
      • Example: 4
    • showTodayButton - Toggles the visibility of the today-button.
      • Optional
      • Type: boolean
      • Example: false
    • todayButtonLabel - Label for the today-button
      • Optional
      • Type: string
      • Example: "Today"
    • customControl - Overwrite the default FormControl component with your own component.
      • Optional
      • Type: React.Component
      • Example: <CustomControl />
  • Methods:

Tests

Browser Coverage

Karma tests are performed on Browserstack in the following browsers:

  • IE 9, Windows 7
  • IE 10, Windows 7
  • IE 11, Windows 7
  • Opera (latest version), Windows 7
  • Firefox (latest version), Windows 7
  • Chrome (latest version), Windows 7
  • Safari (latest version), OSX Yosemite
  • Mobile Safari (latest version), iPhone 6, iOS 8.3

Please let us know if a different configuration should be included here.

Running Tests

Locally:

npm test

On Browserstack:

BROWSERSTACK_USERNAME=YOUR_USERNAME BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY npm test

react-bootstrap-date-picker's People

Contributors

bpugh avatar charliecochran avatar chrismashie avatar dbenfouzari avatar docrinehart avatar ebrenes avatar hoest avatar hugo avatar jlag34 avatar jonshort avatar jvarho avatar kutyel avatar luketherrien avatar nareshbhatia avatar nickjs avatar nift avatar olegserov avatar reggino avatar richardwithnell avatar rikku-1 avatar travellingprog avatar wehriam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-bootstrap-date-picker's Issues

IE11 onBlur not supported

Hi,
First thanks for such an awesome widget, unfortunately Im having an issue when testing on IE11, it can't support the onBlur event, it says this event is not supported, is there a walk around for this or are you planing to solve this issue in a future version of react-bootstrap-date-picker.

Thanks for your help.

Uncaught TypeError: Cannot read property 'Addon' of undefined

Hey, I'm getting these errors in my console when I add the datepicker component to an app.

Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `DatePicker`.
Uncaught TypeError: Cannot read property 'Addon' of undefined

Not sure what to do. any ideas?

Thanks

Getting Error in MacOS

Uncaught RangeError: Invalid time value
at Date.toISOString ()
at Object.makeDateValues

Readme Is Misleading for ES5 Projects

consider including instructions for importing your project to an ES5 project. For ES5 projects, change the first line of usage to
var DatePicker = require("react-bootstrap-date-picker").default;

className and style props should be added

It seems that if I set a prop called className, it is not passed on to the FormControl and is ignored. Likewise, there is no style prop set so I cannot set the style either. These should be supported so the CSS can be modified like all other bootstrap components.

January 2017 wrong dates

Hey there!
First of all, great job on datepicker, working very well. Just found about it today and perfectly suits my needs.
But when I implemented and started testing, I found a bug which is that all dates for January 2017 are wrong. Everything else shows correctly.

https://www.dropbox.com/s/ijn027dpe5aikjj/Screenshot%202016-10-13%2016.32.49.png?dl=0

1st of January should be Sunday.

UPDATE
I noticed that this only happens if I have weekStartsOnMonday set to true. If it is else it works good. Also checked your examples page http://pushtell.github.io/react-bootstrap-date-picker/ and bug also exists there when using datepicker which starts with Monday..

Wrong order of components within input group

The order of the components within the input group causes the wrong styling. Usually, the Input control goes first which allows the left side of the input to have a cornered border.

Normal styling

But in this package the input does not come first, the styling is lost and you end up without the rounded borders.

Wrong styling

I suggest the input component should go first.

Formatting selected date

Hi, I've been struggling to get a displayed format like '05/Jan/2016' which would normally be "DD/MMM/YYYY".

The usage is the following:
<DatePicker value={this.props.dateOpened} onChange={(value) => this.handleChange("dateOpened", value)} type="date" dateFormat="DD/MMM/YYYY"/>

The result is "YYYY/MM/DD" instead:

image

Is there a way of achieving the initial intention?

defaultValue support

It would be nice to have the React defaultValue attribute supported by DatePicker

Input box allows invalid characters to be passed in

Was able to put a good date in then space then random characters then delete date to get an invalid date w/o receiving an complaint from the component.

Example:

  1. 10/03/2016
  2. 10/03/2016 alkdfa
  3. al/kd/fa

The date 10/03/2016 is still captured, but should be validation catching or stopping this kind of input.

Warning: "hasFeedback" property of "FormGroup" has been deprecated.

Is it corrent that I get the following error message in my console log:

Warning: <Input> is deprecated. Use <FormControl>, <Checkbox>, or <Radio>, with <FormGroup> and/or <InputGroup> as needed instead.
Warning: "hasFeedback" property of "FormGroup" has been deprecated.
Use a <FormControl.Feedback> element.

And can you tell me how to fix it? Thank you!

Weird input behaviour

I just started using this literally 2 minutes ago and I've found a problem with the input. I can easily replicate it on your example page: http://pushtell.github.io/react-bootstrap-date-picker/

Click anywhere in the text input box one of the dates that are already entered. Delete and or type a number.

E.g. 06/29/2016. Say you want to change this to the 7th from the 6th. Place the cursor before the first '6', press delete. Result: 09016

Popover id is not unique

If you use the DatePicker component twice on a page you end up with HTML elements having duplicate ids, because the Popover element has a hardcoded id. In addition to being a violation of the spec, this does not play nicely with some other code I'm working with.

I would send a pull request, except I'm not sure what the correct fix is. Changing the value could break someone's code. A new popoverId prop that allows overriding it?

Can't use with the redux-form

I want to use react-bootstrap-date-picker with redux_form. How can i get the value of this field form this.props.field instead of getting it from the on Change event.

Rendering and setState issues

@wehriam,
I get a rendering/layout issue (see attachment), on both Chrome and Firefox, even with this simple component, similar to the example on the doc:

class MyInput extends React.Component {
    constructor(props) {
        super(props);
        this.state =  {
            value: '',
            date: ''
        };
        this.handleChange = this.handleChange.bind(this);
    }
    handleChange(value) {
        // value is an ISO String.
        this.setState({
            value: value,
            date: value.split('T')[0] //just "MM-DD-YYYY"
        });
        console.log(this.state.date);
    }
    render() {
        return <DatePicker value={this.state.value} onChange={this.handleChange}
                           placeholder="MM-DD-YYYY" dateFormat="MM-DD-YYYY"
                           bsSize="small"
        />
    }
}
export default MyInput;

Although it might seem to work, despite the rendering problem, I noticed that the value logged and set, in handleChange(), as date is actually the previously set value and not the current one.
Let me try to explain better with an example: the first time you select a date on the calendar, let's say '05-24-2016', this.state.date is set with (and logged as) an empty string (the initial value). Selecting then another date, e.g. '05-11-2016', it now sets and logs '05-24-2016' as date. On the following date pick it will set '05-11-2016'and so on.

Can you help me with this issues?
I'm using "react": "^15.0.2", "react-bootstrap": "^0.29.4", "react-dom": "^15.0.2" and of course the latest react-bootstrap-date-picker release 3.0.3
Thanks

screen shot 2016-05-24 at 10 55 31 pm

Error: window is not defined

Hello, I got this error, any ideas?

/Users/Elias/noteshare/node_modules/react-bootstrap-date-picker/lib/index.js:189
    var language = (window.navigator.userLanguage || window.navigator.language || '').toLowerCase();
                    ^

ReferenceError: window is not defined
    at Function.getDefaultProps (/Users/Elias/noteshare/node_modules/react-bootstrap-date-picker/lib/index.js:189:21)
    at Object.ReactClass.createClass (/Users/Elias/noteshare/node_modules/react/lib/ReactClass.js:682:46)
    at Object.<anonymous> (/Users/Elias/noteshare/node_modules/react-bootstrap-date-picker/lib/index.js:173:35)
    at Module._compile (module.js:409:26)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/Elias/noteshare/node_modules/node-jsx/index.js:29:12)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/Elias/noteshare/ui/common/topbar/uploadButton.jsx:17:18)

Support of monday-starting week

Hello,

I've been using your lib for a month now and it's really great, but I've been wondering if you would consider supporting monday-starting weeks?

Thanks in advance, keep up the good work!

Testing validations on date picker

I am currently trying to test validations on a form where I am using react-bootstrap-date-picker however I am having a couple of issues.

In the view I can see that the validations are working correctly, but in the tests something isn't quite right.

I am using react-addons-test-utils Simulate like this:

Simulate.change(formFields[2], { target: { value: '04/01/2017' } }); in this instance formFields[2] is the date picker however unlike other input fields when I log the value out to the console it is still blank, I was wondering if anyone has a working test example for something like this that could point me in the right direction?

Warning about controlId

Has next warning in console

Warning: `controlId` is ignored on `<FormControl>` when `id` is specified.

My code:

            <FormGroup controlId="start_date">
              <Col componentClass={ControlLabel} sm={3}>
                Start date
              </Col>
              <Col sm={9}>
                <DatePicker ref="startDateInput" />
              </Col>
            </FormGroup>

I know I may remove controlId prop form FormGroup, but in this case how I may assign label for input? I want user to be able to click on label to make input in focus.

Min and max date support

Nice component! It would be awesome if it have support for min and max date, any way to get that kind of functionality out of the box?

Control the clear button visibility

Hi,
Thanks for this great component, is it possible to control the visibility of the clear button.
I have a case which i want to use 2 datePickers and beside them a clear button to clear them both
so i want to remove the clear for the individual component.

Can't select date

I am getting this weird error where I can't select the date from the popover. If I manually change the date, the onChange event occurs. But, when I try to select a date, nothing happens. I have put a few console.logs in there. The onChange isn't being called. There are multiple datepickers but each has a unique ID.

The render method for that component is being called each time I click on a date. I don't know what is causing this though. What am I doing wrong?

This is how I have it setup:
import DatePicker from "react-bootstrap-date-picker";

<DatePicker
                    id={"due-date-datepicker-" + id}  << (ID is the object ID of the item being selected)
                    disabled={false}
                    placeholder="Select due date..."
                    dateFormat="MM/DD/YYYY"
                    value={this.state.dueDate}
                    onChange={() => { console.log("DatePicker onChange")}} << (I had this set like the example, but it wasn't being called.)
                    onFocus={() => { console.log("DatePicker Focus")}}
                    onBlur={() => { console.log("DatePicker Blur")}}
                  />

Addons improvement

Hi @wehriam,
I tried to implement the possibility to add an Addon before the date field and to show or not the clear Addon, but when I click on the input filed I get an error I can't understand:
Uncaught TypeError: Cannot set property top of #<ClientRect> which has only a getter

I am pretty new to ReactJS, so I must have done a dumb error; this is my version (with obvious changes in props):

    render() {
        const calendarHeader = <CalendarHeader
            previousButtonElement={this.props.previousButtonElement}
            nextButtonElement={this.props.nextButtonElement}
            displayDate={this.state.displayDate}
            onChange={this.onChangeMonth}
            monthLabels={this.props.monthLabels}
            dateFormat={this.props.dateFormat}/>;

        const preAddon = (this.props.preAddon) ? <InputGroup.Addon>{this.props.preAddon}</InputGroup.Addon> : '';
        let clearAddon = '';
        if (this.props.showClear) {
            clearAddon = <InputGroup.Addon onClick={this.clear}
                                           style={{cursor:this.state.inputValue ? "pointer" : "not-allowed"}}>
                                    {this.props.clearButtonElement}
                         </InputGroup.Addon>
        }
        return <InputGroup ref="inputGroup" bsClass={this.props.bsClass} bsSize={this.props.bsSize}
                           id={this.props.id ? this.props.id + "_group" : null}>
            <Overlay rootClose={true} onHide={this.handleHide} show={this.state.focused}
                     container={() => ReactDOM.findDOMNode(this.refs.overlayContainer)}
                     target={() => ReactDOM.findDOMNode(this.refs.input)} placement={this.props.calendarPlacement}
                     delayHide={200}>
                <Popover id="calendar" title={calendarHeader}>
                    <Calendar cellPadding={this.props.cellPadding} selectedDate={this.state.selectedDate}
                              displayDate={this.state.displayDate} onChange={this.onChangeDate}
                              dayLabels={this.props.dayLabels}/>
                </Popover>
            </Overlay>
            <div ref="overlayContainer"/>
            <input type="hidden" id={this.props.id} name={this.props.name} value={this.state.value || ''}/>
            {preAddon}
            <FormControl
                onKeyDown={this.handleKeyDown}
                value={this.state.inputValue || ''}
                ref="input"
                type="text"
                placeholder={this.state.focused ? this.props.dateFormat : this.state.placeholder}
                onFocus={this.handleFocus}
                onBlur={this.handleBlur}
                onChange={this.handleInputChange}
                name={null}
                id={null}
            />
            {clearAddon}
        </InputGroup>;
    }

and this is how I create my component:

<MyDatePicker value={this.state.value} onChange={this.handleChange}
      clearButtonElement={<Glyphicon glyph="remove"/>}
      preAddon={<Glyphicon glyph="calendar"/>}
      placeholder="MM-DD-YYYY" dateFormat="MM-DD-YYYY" bsSize="small"
/>

Where do you think I'm wrong?
Thanks

Blur event fired after clicking inside Datepicker.

Component triggers a blur event when the user makes their first interaction with the datepicker. As the component is still actionable and in focus, the component should be changed so that it fires a blur event when the component is truly closed and no longer in focus.

Usage inside navbar form is broken

Since the outermost element is a div without any css/styles it breaks the inline style of navbar forms.

I fixed it by adding display:inline-block via css but maybe consider changing it to a span or adding some inline style.

screen shot 2016-04-18 at 13 52 57

my fix:

.navbar-form { div { display: inline-block; } }

screen shot 2016-04-18 at 13 54 04

thanks.

Custom placeholder changes to default onFocus

We need to use localized placeholder (for german language), so instead of DD.MM.YYYY we set TT.MM.JJJJ, like this:
<DatePicker placeholder="TT.MM.JJJJ" {...otherProps}/>
Everything works fine before user clicks on input => custom placeholder is replaced by default DD.MM.YYYY
I think, custom placeholder shouldn't be overriden.

Passing in additional classes

<DatePicker
   value={this.props.date}
   onChange={this.changeDate}
   clearButtonElement={'Today'}
   calssName="form-control u-input"
 />

Not work as my mind, How to pass additional classes?

Need the possibility to enable and disable the datepicker based on the application state.

I miss the feature to render the datepicker and field in a disabled readonly state.

When using in a form, many values will be system managed and read only after these have been created.

It gets quite cluttered when alternating between a normal disabled input field and the datepicker to support this in the front end files. It would be much cleaner having disabled support on the component.

Clear button causes errors

Hello! I am using your date-picker in a web app and having some issues. The date picking functions work well, I have the initial value set to '' which displays the placeholder. When the value is set to '', I have the adjacent table displaying all values. When a date is selected, the filter function I created shows all dates after the selected date in the table. The trouble comes when trying to clear the fields. When I press the clear button, I get an "uncaught RangeError: Invalid time value" which breaks the component. The actual value that is placed in the object is "Invalid Date", which causes the error in the code for the date-picker. I have tried to handle this externally in my code, however it seems like the "Invalid Date" breaks something in the date-picker itself. Ideally, I would just like to set the date-picker back to the starting state of ''. Is that possible? Am I missing something? Thanks in advance for your help. Attached
screen shot 2016-06-06 at 3 35 13 pm
is the stack trace from the error.

onChange should pass through full event object

The onChange event from DatePicker should pass on the full event object with the value in event.target.value so that the event can be handled and the value found in the standard location.

toISOString fails in Safari but not Chrome

Hello.

Im currenly faced wit the issue of toISOString fails in a safari browser when i try to run it in the value attribute.

<DatePicker value={this.props.todo.deadline} placeholder="Deadline"/>

When im mounting the component in Safari i get a error with toISOString. but the error is non replicatateable in Chrome.

Testable ISO String 2016-03-31T10:00:00+0000

DatePicker returns values with time

Using a date-picker, I would only expect to get a "date" not a "datetime". If I wanted to have a time and/or timezone attached to the data, I'd use a datetime picker.

I manually append times and timezones based on configuration and user-entered values, so when the date I expect already has something for those, it causes strange offset bugs. I have to scrub the times out before I can do anything with the data, which is tedious the more date fields that get added.

If the value MUST be ISO-8601, I'd suggest ensuring that time and offset are set to 0.

The calendar popover is clipped when placed in a scrollable container

When I place the react-bootstrap-date-picker in a scrollable container and I click in the input field, the calendar pops up but it is clipped to the container boundary. If I put up a raw react-bootstrap popover next to it, this popover correctly shows in full, sitting on top of the scrollable container. How can I make the react-bootstrap-date-picker behave the same way?

image

Here's my code:

    render() {
        return (
            <div className={ style['bulk-processing'] + ' panel panel-primary' } >
                <div className="panel-heading">Scrollable Panel</div>
                <div className="panel-body scrollable">
                    <Popover
                        id="popover-basic"
                        placement="right"
                        positionLeft={325}
                        positionTop={50}
                        title="Popover right"
                    >
                        And here's some <strong>amazing</strong> content. It's very engaging. right?
                    </Popover>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/>
                    Hello World<br/><br/>

                    <div className="container-fluid">
                        <div className="col-xs-4">
                            <DatePicker
                                id="start-date"
                                dateFormat="MM/DD/YYYY"
                            />
                        </div>
                    </div>
                </div>
            </div>
        );
    }

The scrollable class is defined as follows:

.scrollable {
    -ms-overflow-style: scrollbar;
    overflow: auto;
}

Default value doesn't work

<DatePicker
ref={(testDate) => { testDateInput = testDate }}
defaultValue={testDate}
dateFormat='YYYY-MM-DD'
/>

But the input field, doen't display the default value

Datepicker daylight saving creates incorrect date selection

Say I am on date '2016-11-05' when I select a date that is on or below '2016-10-30' the return value is incorrect. If I am selecting '2016-10-29' I will get '2016-10-28 23:00:00'. I would expect the date picker to be daylight savings time agnostic.

How can I fix this?

How to handle defaultValue in an update/edit form?

My dates are being stored as ISO strings "2016-08-18T16:00:00.000Z"

I'm wondering what I need to do to give a default value to the DatePicker input in my edit/update forms?

For all my other inputs, which are using formsy-react, I'm just passing an event prop and doing defaultValue={this.props.event.inputValue}. This doesn't seem to work with the date input when I pass it to the value={this.props.event.date}

Do I have to convert the ISO string back to a number for it to work? This doesn't seem to work either:

value={Date.parse(this.props.event.date)}

Because there is no defaultValue prop and only a value prop, do I need to setup local state with an onChange inside my update form to not only give the initial default value but also capture the changed value for updating/editing?

Update:

I guess my dates are stored as ISO strings in the database, but back on the client I'm console logging this from my props:

Wed Aug 24 2016 12:00:00 GMT-0400 (EDT)

onChange(newValue) contains hour even if date format is DD.MM.YYYY

For ex:

2016-10-31T23:00:00.000Z

Which is completely wrong, because 1) the date picker doesnt support picking time and 2) if the hour is 23 and the date is 31th of October, we get timezone issues with the date picker rendering a displayed value of 01.11.2016.

Can you fix this?

Warnings in Console

I keep getting this warnings in the developer tools console:

screen shot 2016-05-05 at 11 43 20 am

May be I'm missing something?

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.