Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Commit c3bd0bd

Browse files
committed
Fixes setSelectedDate
1 parent 7edbf53 commit c3bd0bd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/coffee/DateTimeField.jsx.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ DateTimeField = React.createClass(
3232

3333
componentWillReceiveProps: (nextProps) ->
3434
@setState
35-
viewDate: moment(nextProps.dateTime).startOf("month")
36-
selectedDate: moment(nextProps.dateTime)
37-
inputValue: moment(nextProps.dateTime).format(nextProps.inputFormat)
35+
viewDate: moment(nextProps.dateTime, nextProps.format).startOf("month")
36+
selectedDate: moment(nextProps.dateTime, nextProps.format)
37+
inputValue: moment(nextProps.dateTime, nextProps.format).format(nextProps.inputFormat)
3838

3939
# to improve with detection only onBlur
4040
onChange: (event) ->
@@ -49,7 +49,7 @@ DateTimeField = React.createClass(
4949
@props.onChange(@state.selectedDate.format(@props.format))
5050

5151
setSelectedDate: (e) ->
52-
@setState selectedDate: @state.viewDate.clone().date(parseInt(e.target.innerHTML)), ->
52+
@setState selectedDate: @state.viewDate.clone().date(parseInt(e.target.innerHTML)).hour(@state.selectedDate.hours()).minute(@state.selectedDate.minutes()), ->
5353
@closePicker()
5454
@props.onChange(@state.selectedDate.format(@props.format))
5555
@setState inputValue: @state.selectedDate.format("MM/DD/YY H:mm A")

0 commit comments

Comments
 (0)