@momo-kits/date-picker 0.0.62-alpha.18 → 0.0.62-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,7 +72,6 @@ class DatePicker extends Component {
72
72
  constructor(props) {
73
73
  super(props);
74
74
  this.initDefault(props);
75
- console.log('PRops------------', props);
76
75
  }
77
76
 
78
77
  // onBackPress = () => {
@@ -251,9 +250,6 @@ class DatePicker extends Component {
251
250
  this.selectedDate?.to?.getMinutes()?.toString(),
252
251
  )}`
253
252
  : '00:00';
254
- console.log('Value hour 1', this.selectedDate.from);
255
- console.log('Value hour 2', this.selectedDate.to);
256
- console.log('Selected date', this.selectedDate);
257
253
  this.hourRangeIndex_1 = valueHours_1
258
254
  ? this.ranged.indexOf(valueHours_1)
259
255
  : this.ranged.indexOf(
@@ -547,7 +543,6 @@ class DatePicker extends Component {
547
543
  if (!this.arrayRef) {
548
544
  this.arrayRef = {};
549
545
  }
550
- console.log('valueInput------------', valueInput);
551
546
  return (
552
547
  <WheelPicker
553
548
  bottomOffset={bottomOffset}
@@ -49,7 +49,7 @@ export default class DatePickerHelper {
49
49
  '22:00',
50
50
  '22:30',
51
51
  '23:00',
52
- '23:30'
52
+ '23:30',
53
53
  ];
54
54
 
55
55
  static makeRange(min, max, isDouble) {
@@ -57,7 +57,8 @@ export default class DatePickerHelper {
57
57
  // eslint-disable-next-line no-plusplus
58
58
  for (let i = min; i <= max; i++) {
59
59
  const string = String(i);
60
- const value = string.length === 1 && isDouble ? `0${string}` : string;
60
+ const value =
61
+ string.length === 1 && isDouble ? `0${string}` : string;
61
62
  array.push(value);
62
63
  }
63
64
  return array;
@@ -69,7 +70,14 @@ export default class DatePickerHelper {
69
70
  const day = current.getDate().toString();
70
71
  const month = (current.getMonth() + 1).toString();
71
72
  const year = current.getFullYear().toString();
72
- return DatePickerHelper.toString(day, month, year, null, null, format);
73
+ return DatePickerHelper.toString(
74
+ day,
75
+ month,
76
+ year,
77
+ null,
78
+ null,
79
+ format,
80
+ );
73
81
  }
74
82
  return '';
75
83
  }
@@ -77,10 +85,17 @@ export default class DatePickerHelper {
77
85
  static formatDate(date, format) {
78
86
  if (date && format) {
79
87
  const {
80
- year, month, day, hour, minute, second = 0
88
+ year,
89
+ month,
90
+ day,
91
+ hour,
92
+ minute,
93
+ second = 0,
81
94
  } = DatePickerHelper.getDateTimeFromFormat(date, format);
82
- if (DatePickerHelper.checkValidDate(year, month, day)
83
- && DatePickerHelper.checkValidTime(hour, minute, second)) {
95
+ if (
96
+ DatePickerHelper.checkValidDate(year, month, day) &&
97
+ DatePickerHelper.checkValidTime(hour, minute, second)
98
+ ) {
84
99
  return new Date(year, month, day, hour, minute, second);
85
100
  }
86
101
  return null;
@@ -119,8 +134,14 @@ export default class DatePickerHelper {
119
134
 
120
135
  const today = new Date();
121
136
 
122
- const year = yearIndex > -1 ? dateItems?.[yearIndex] : today.getFullYear();
123
- const month = monthIndex > -1 ? dateItems?.[monthIndex] - 1 : today.getMonth() === 0 ? 1 : today.getMonth() - 1;
137
+ const year =
138
+ yearIndex > -1 ? dateItems?.[yearIndex] : today.getFullYear();
139
+ const month =
140
+ monthIndex > -1
141
+ ? dateItems?.[monthIndex] - 1
142
+ : today.getMonth() === 0
143
+ ? 1
144
+ : today.getMonth() - 1;
124
145
  const day = dayIndex > -1 ? dateItems?.[dayIndex] : today.getDate();
125
146
 
126
147
  const hour = hourIndex > -1 ? dateItems[hourIndex] : 0;
@@ -142,7 +163,7 @@ export default class DatePickerHelper {
142
163
  return number;
143
164
  }
144
165
  return `0${number}`;
145
- }
166
+ };
146
167
 
147
168
  static toString(day, month, year, hour, minute, format) {
148
169
  if (day && month && year && format) {
@@ -160,24 +181,32 @@ export default class DatePickerHelper {
160
181
  const year = parseInt(y);
161
182
  const month = parseInt(m);
162
183
  const day = parseInt(d);
163
- const months31 = [0, 2, 4, 6, 7, 9, 11];
164
- const months30 = [3, 5, 8, 10];
165
- const months28 = [1];
166
- const isLeap = ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
184
+ const months31 = [1, 3, 5, 7, 8, 10, 12];
185
+ const months30 = [4, 6, 9, 11];
186
+ const months28 = [2];
187
+ const isLeap = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
167
188
  if (year != null && month != null && day != null) {
168
189
  const isDayValid = day > 0;
169
- const isMonthValid = (months31.indexOf(parseInt(month)) != -1 && day <= 31)
170
- || (months30.indexOf(month) != -1 && day <= 30)
171
- || (months30.indexOf(month) != -1 && day <= 31)
172
- || (months28.indexOf(month) != -1 && day <= 28)
173
- || (months28.indexOf(month) != -1 && day <= 29 && isLeap);
190
+ const isMonthValid =
191
+ (months31.indexOf(parseInt(month)) != -1 && day <= 31) ||
192
+ (months30.indexOf(month) != -1 && day <= 30) ||
193
+ (months30.indexOf(month) != -1 && day <= 31) ||
194
+ (months28.indexOf(month) != -1 && day <= 28) ||
195
+ (months28.indexOf(month) != -1 && day <= 29 && isLeap);
174
196
  return isDayValid && isMonthValid;
175
197
  }
176
198
  return false;
177
199
  }
178
200
 
179
201
  static checkValidTime(hour, minute, second) {
180
- if ((hour >= 0 && hour < 24) && (minute >= 0 && minute < 60) && (second >= 0 && second < 60)) {
202
+ if (
203
+ hour >= 0 &&
204
+ hour < 24 &&
205
+ minute >= 0 &&
206
+ minute < 60 &&
207
+ second >= 0 &&
208
+ second < 60
209
+ ) {
181
210
  return true;
182
211
  }
183
212
  return false;
@@ -185,11 +214,18 @@ export default class DatePickerHelper {
185
214
 
186
215
  static calculateDateSinceYearAgo(yearAgo) {
187
216
  let nowDate = new Date();
188
- nowDate = new Date(nowDate.getFullYear() - yearAgo, nowDate.getMonth(), nowDate.getDate());
217
+ nowDate = new Date(
218
+ nowDate.getFullYear() - yearAgo,
219
+ nowDate.getMonth(),
220
+ nowDate.getDate(),
221
+ );
189
222
  return nowDate;
190
223
  }
191
224
 
192
- static getMaxDate(month = new Date().getMonth(), year = new Date().getFullYear()) {
225
+ static getMaxDate(
226
+ month = new Date().getMonth(),
227
+ year = new Date().getFullYear(),
228
+ ) {
193
229
  const monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
194
230
  // Adjust for leap years
195
231
  if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) {
@@ -201,5 +237,5 @@ export default class DatePickerHelper {
201
237
 
202
238
  static capitalizeFirstLetter(string) {
203
239
  return string.charAt(0).toUpperCase() + string.slice(1);
204
- }
240
+ }
205
241
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/date-picker",
3
- "version": "0.0.62-alpha.18",
3
+ "version": "0.0.62-alpha.20",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},
@@ -13,4 +13,4 @@
13
13
  },
14
14
  "devDependencies": {},
15
15
  "license": "MoMo"
16
- }
16
+ }