From 5c813ae4177b1257b0a1f0a36c349e06fceb52a6 Mon Sep 17 00:00:00 2001 From: Stephen Sugden Date: Fri, 17 Nov 2017 11:07:21 +0100 Subject: [PATCH 1/2] Document return type of `date` knob (see #1489) --- addons/knobs/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/knobs/README.md b/addons/knobs/README.md index e70eb53e5a30..cd343a75172f 100644 --- a/addons/knobs/README.md +++ b/addons/knobs/README.md @@ -235,6 +235,16 @@ const value = date(label, defaultValue); > Note: the default value must not change - e.g., do not do `date('Label', new Date())` or `date('Label')` +The `date` knob returns the selected date as stringified Unix timestamp (e.g. `"1510913096516"`). +If your componentneeds the date in a different form you can wrap the `date` function: + +``` +function myDateKnob(name, defaultValue) { + const stringTimestamp = date(name, defaultValue) + return new Date(stringTimestamp) +} +``` + ### button Allows you to include a button and associated handler. From 96c422667aec8e27152beeede516f9bbe7166cfa Mon Sep 17 00:00:00 2001 From: Stephen Sugden Date: Fri, 17 Nov 2017 11:09:39 +0100 Subject: [PATCH 2/2] Fix typo --- addons/knobs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/knobs/README.md b/addons/knobs/README.md index cd343a75172f..e37638fb5533 100644 --- a/addons/knobs/README.md +++ b/addons/knobs/README.md @@ -236,7 +236,7 @@ const value = date(label, defaultValue); > Note: the default value must not change - e.g., do not do `date('Label', new Date())` or `date('Label')` The `date` knob returns the selected date as stringified Unix timestamp (e.g. `"1510913096516"`). -If your componentneeds the date in a different form you can wrap the `date` function: +If your component needs the date in a different form you can wrap the `date` function: ``` function myDateKnob(name, defaultValue) {