diff --git a/README.md b/README.md
index 1a06812..2d7391b 100644
--- a/README.md
+++ b/README.md
@@ -99,7 +99,9 @@ export default Example;
| Prop | Type | Description | Default |
| -------------- | -------- | ---------------------------------------------- | ------- |
+| minHour | number | Minimum of hour | 0 |
| maxHour | number | Maximum of hour | 23 |
+| minMinute | number | Minimum of minute | 0 |
| maxMinute | number | Maximum of minute | 59 |
| hourInterval | number | The interval at which hours can be selected. | 1 |
| minuteInterval | number | The interval at which minutes can be selected. | 1 |
diff --git a/index.d.ts b/index.d.ts
index 8b21fef..8e11e23 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -3,7 +3,9 @@ import { StyleProp, ViewStyle } from "react-native";
declare module "react-native-24h-timepicker" {
export type TimePickerProps = {
+ minHour?: number;
maxHour?: number;
+ minMinute?: number;
maxMinute?: number;
hourInterval?: number;
minuteInterval?: number;
diff --git a/src/index.js b/src/index.js
index 14e68e6..2d5f05c 100644
--- a/src/index.js
+++ b/src/index.js
@@ -23,33 +23,26 @@ class TimePicker extends Component {
getHourItems = () => {
const items = [];
- const { maxHour, hourInterval, hourUnit } = this.props;
- const interval = maxHour / hourInterval;
- for (let i = 0; i <= interval; i++) {
- const value = `${i * hourInterval}`;
+ const { minHour, maxHour, hourInterval, hourUnit } = this.props;
+ for (let i = minHour; i <= maxHour; i=i+hourInterval){
+ const value = `${i}`;
const item = (
);
- items.push(item);
+ items.push(item);
}
return items;
};
getMinuteItems = () => {
const items = [];
- const { maxMinute, minuteInterval, minuteUnit } = this.props;
- const interval = maxMinute / minuteInterval;
- for (let i = 0; i <= interval; i++) {
- const value = i * minuteInterval;
- const new_value = value < 10 ? `0${value}` : `${value}`;
+ const { minMinute, maxMinute, minuteInterval, minuteUnit } = this.props;
+ for (let i = minMinute; i <= maxMinute; i=i+minuteInterval){
+ const value = value < 10 ? `0${i}` : `${i}`;
const item = (
-
+
);
- items.push(item);
+ items.push(item);
}
return items;
};
@@ -140,7 +133,9 @@ class TimePicker extends Component {
}
TimePicker.propTypes = {
+ minHour: PropTypes.number,
maxHour: PropTypes.number,
+ minMinute: PropTypes.number,
maxMinute: PropTypes.number,
hourInterval: PropTypes.number,
minuteInterval: PropTypes.number,
@@ -156,7 +151,9 @@ TimePicker.propTypes = {
};
TimePicker.defaultProps = {
+ minHour: 0,
maxHour: 23,
+ minMinute: 0,
maxMinute: 59,
hourInterval: 1,
minuteInterval: 1,