From dd2f6abda00cea99ec0a24e3f162fabeba7ac176 Mon Sep 17 00:00:00 2001
From: Antony Shaleynikov <shaleynikov@gmail.com>
Date: Thu, 2 Mar 2017 15:42:05 +0300
Subject: Updated 12 hours example, added default format for 12 hours mode,
 updated tests

---
 src/TimePicker.jsx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'src/TimePicker.jsx')

diff --git a/src/TimePicker.jsx b/src/TimePicker.jsx
index 6b76223..7065333 100644
--- a/src/TimePicker.jsx
+++ b/src/TimePicker.jsx
@@ -128,10 +128,21 @@ const Picker = React.createClass({
   },
 
   getFormat() {
-    const { format, showHour, showMinute, showSecond } = this.props;
+    const { format, showHour, showMinute, showSecond, use12Hours } = this.props;
     if (format) {
       return format;
     }
+
+    if (use12Hours) {
+      const fmtString = ([
+        showHour ? 'h' : '',
+        showMinute ? 'mm' : '',
+        showSecond ? 'ss' : '',
+      ].filter(item => !!item).join(':'));
+
+      return fmtString.concat(' a');
+    }
+
     return [
       showHour ? 'HH' : '',
       showMinute ? 'mm' : '',
-- 
cgit v1.2.3

