From 43f4955962774edff066abb4ca864b27dc14fdf2 Mon Sep 17 00:00:00 2001 From: mbrookes Date: Tue, 1 Dec 2015 17:05:03 +0000 Subject: [PATCH] Fix default (ISO8601 style) date for formatDate to respect client timezone --- CHANGELOG.md | 1 + package.json | 2 +- src/FormsyDate.jsx | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b73db89..4f911d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog +* 0.3.3 Fix default (ISO8601 style) date for formatDate to respect client timezone * 0.3.2 Remove explicit files declaration from package.json (the npm docs lie!) * 0.3.1 Add ./lib/ to package.json. * 0.3.0 Split into separate files to allow individual import of MUI components diff --git a/package.json b/package.json index e5e712e..cdcac5d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "formsy-material-ui", - "version": "0.3.2", + "version": "0.3.3", "description": "A formsy-react compatibility wrapper for Material-UI form components.", "main": "index.js", diff --git a/src/FormsyDate.jsx b/src/FormsyDate.jsx index 73547e4..f64722f 100644 --- a/src/FormsyDate.jsx +++ b/src/FormsyDate.jsx @@ -9,9 +9,13 @@ let FormsyDate = React.createClass({ render: function () { return ( date.toISOString().substring(0,10)} + // Sets the default date format to be ISO8601 (YYYY-MM-DD), accounting for current timezone + formatDate={(date) => (new Date(date.toDateString()+" 12:00:00 +0000")).toISOString().substring(0,10)} {...this.props} - onChange={this.handleValueChange} /> + defaultValue={this.props.value} + onChange={this.handleValueChange} + errorText={this.getErrorMessage()} + value={this.getValue()} /> ); } });