道路线索应急巡查系统服务后台
feiyu02
2025-04-22 41548e262362faf603a71e066e01bd4ef46619d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
package com.flightfeather.grid.utils
 
import java.sql.Timestamp
import java.text.ParsePosition
import java.text.SimpleDateFormat
import java.util.*
 
object DateUtil {
    private val threadLocal = ThreadLocal<SimpleDateFormat>()
 
    private val `object` = Any()
 
    /**
     * 获取SimpleDateFormat
     * @param pattern 日期格式
     * @return SimpleDateFormat对象
     * @throws RuntimeException 异常:非法日期格式
     */
    @Throws(RuntimeException::class)
    private fun getDateFormat(pattern: String): SimpleDateFormat {
        var dateFormat: SimpleDateFormat? = threadLocal.get()
        if (dateFormat == null) {
            synchronized(`object`) {
                if (dateFormat == null) {
                    dateFormat = SimpleDateFormat(pattern)
                    dateFormat!!.isLenient = false
                    threadLocal.set(dateFormat)
                }
            }
        }
        dateFormat!!.applyPattern(pattern)
        return dateFormat as SimpleDateFormat
    }
 
    /**
     * 获取日期中的某数值。如获取月份
     * @param date 日期
     * @param dateType 日期格式
     * @return 数值
     */
    private fun getInteger(date: Date?, dateType: Int): Int {
        var num = 0
        val calendar = Calendar.getInstance()
        if (date != null) {
            calendar.time = date
            num = calendar.get(dateType)
        }
        return num
    }
 
    /**
     * 增加日期中某类型的某数值。如增加日期
     * @param date 日期字符串
     * @param dateType 类型
     * @param amount 数值
     * @return 计算后日期字符串
     */
    private fun addInteger(date: String, dateType: Int, amount: Int): String? {
        var dateString: String? = null
        val dateStyle = getDateStyle(date)
        if (dateStyle != null) {
            var myDate = stringToDate(date, dateStyle)
            myDate = addInteger(myDate, dateType, amount)
            dateString = DateToString(myDate, dateStyle)
        }
        return dateString
    }
 
    /**
     * 增加日期中某类型的某数值。如增加日期
     * @param date 日期
     * @param dateType 类型
     * @param amount 数值
     * @return 计算后日期
     */
    private fun addInteger(date: Date?, dateType: Int, amount: Int): Date? {
        var myDate: Date? = null
        if (date != null) {
            val calendar = Calendar.getInstance()
            calendar.time = date
            calendar.add(dateType, amount)
            myDate = calendar.time
        }
        return myDate
    }
 
    /**
     * 获取精确的日期
     * @param timestamps 时间long集合
     * @return 日期
     */
    private fun getAccurateDate(timestamps: List<Long>?): Date? {
        var date: Date? = null
        var timestamp: Long = 0
        val map = HashMap<Long, LongArray>()
        val absoluteValues = ArrayList<Long>()
 
        if (timestamps != null && timestamps.size > 0) {
            if (timestamps.size > 1) {
                for (i in timestamps.indices) {
                    for (j in i + 1 until timestamps.size) {
                        val absoluteValue = Math.abs(timestamps[i] - timestamps[j])
                        absoluteValues.add(absoluteValue)
                        val timestampTmp = longArrayOf(timestamps[i], timestamps[j])
                        map.put(absoluteValue, timestampTmp)
                    }
                }
 
                // 有可能有相等的情况。如2012-11和2012-11-01。时间戳是相等的。此时minAbsoluteValue为0
                // 因此不能将minAbsoluteValue取默认值0
                var minAbsoluteValue: Long = -1
                if (!absoluteValues.isEmpty()) {
                    minAbsoluteValue = absoluteValues[0]
                    for (i in 1 until absoluteValues.size) {
                        if (minAbsoluteValue > absoluteValues[i]) {
                            minAbsoluteValue = absoluteValues[i]
                        }
                    }
                }
 
                if (!minAbsoluteValue.equals(-1)) {
                    val timestampsLastTmp = map[minAbsoluteValue]
 
                    val dateOne = timestampsLastTmp?.get(0)
                    val dateTwo = timestampsLastTmp?.get(1)
                    if (absoluteValues.size > 1) {
                        timestamp = if (Math.abs(dateOne!!) > Math.abs(dateTwo!!)) dateOne else dateTwo
                    }
                }
            } else {
                timestamp = timestamps[0]
            }
        }
 
        if (timestamp != 0L) {
            date = Date(timestamp)
        }
        return date
    }
 
    /**
     * 判断字符串是否为日期字符串
     * @param date 日期字符串
     * @return true or false
     */
    fun isDate(date: String?): Boolean {
        var isDate = false
        if (date != null) {
            if (getDateStyle(date) != null) {
                isDate = true
            }
        }
        return isDate
    }
 
    /**
     * 获取日期字符串的日期风格。失敗返回null。
     * @param date 日期字符串
     * @return 日期风格
     */
    fun getDateStyle(date: String?): DateStyle? {
        var dateStyle: DateStyle? = null
        val map = HashMap<Long, DateStyle>()
        val timestamps = ArrayList<Long>()
        for (style in DateStyle.values()) {
            if (style.isShowOnly) {
                continue
            }
            var dateTmp: Date? = null
            if (date != null) {
                try {
                    val pos = ParsePosition(0)
                    dateTmp = getDateFormat(style.value).parse(date, pos)
                    if (pos.index != date.length) {
                        dateTmp = null
                    }
                } catch (e: Exception) {
                }
 
            }
            if (dateTmp != null) {
                timestamps.add(dateTmp.time)
                map.put(dateTmp.time, style)
            }
        }
        val accurateDate = getAccurateDate(timestamps)
        if (accurateDate != null) {
            dateStyle = map[accurateDate.time]
        }
        return dateStyle
    }
 
 
    /**
     * Timestamp -> String
     *
     */
    fun timestampToString(ts: Timestamp, format: String): String {
        var tsStr = ""
        val sdf = SimpleDateFormat(format)
        try {
            //方法一
            tsStr = sdf.format(ts)
        } catch (e: Exception) {
            e.printStackTrace()
        }
 
        return tsStr
    }
 
    /**
     * 将日期字符串转化为日期。失败返回null。
     * @param date 日期字符串
     * @return 日期
     */
    fun stringToDate(date: String?): Date? {
        val dateStyle = getDateStyle(date)
        return stringToDate(date, dateStyle)
    }
 
    /**
     * 将日期字符串转化为日期。失败返回null。
     * @param date 日期字符串
     * @param pattern 日期格式
     * @return 日期
     */
    fun stringToDate(date: String?, pattern: String): Date? {
        var myDate: Date? = null
        if (date != null) {
            try {
                myDate = getDateFormat(pattern).parse(date)
            } catch (e: Exception) {
            }
 
        }
        return myDate
    }
 
    /**
     * 将日期字符串转化为日期。失败返回null。
     * @param date 日期字符串
     * @param dateStyle 日期风格
     * @return 日期
     */
    fun stringToDate(date: String?, dateStyle: DateStyle?): Date? {
        var myDate: Date? = null
        if (dateStyle != null) {
            myDate = stringToDate(date, dateStyle.value)
        }
        return myDate
    }
 
    /**
     * 将日期字符串转化为日期。失败返回null。
     * @param millisecondStamp 日期时间戳
     * @param dateStyle 日期风格
     * @return 日期
     */
    fun LongToString(millisecondStamp: Long?, dateStyle: DateStyle?): String? {
        var dateString: String? = null
        if (dateStyle != null) {
            dateString = DateToString(Date(millisecondStamp!!), dateStyle.value)
        }
        return dateString
    }
 
    /**
     * 将日期转化为日期字符串。失败返回null。
     * @param date 日期
     * @param pattern 日期格式
     * @return 日期字符串
     */
    fun DateToString(date: Date?, pattern: String): String? {
        var dateString: String? = null
        if (date != null) {
            try {
                dateString = getDateFormat(pattern).format(date)
            } catch (e: Exception) {
            }
        }
        return dateString
    }
 
    /**
     * 将日期转化为日期字符串。失败返回null。
     * @param date 日期
     * @param dateStyle 日期风格
     * @return 日期字符串
     */
    fun DateToString(date: Date?, dateStyle: DateStyle?): String? {
        var dateString: String? = null
        if (dateStyle != null) {
            dateString = DateToString(date, dateStyle.value)
        }
        return dateString
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param newPattern 新日期格式
     * @return 新日期字符串
     */
    fun StringToString(date: String, newPattern: String): String? {
        val oldDateStyle = getDateStyle(date)
        return StringToString(date, oldDateStyle, newPattern)
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param newDateStyle 新日期风格
     * @return 新日期字符串
     */
    fun StringToString(date: String, newDateStyle: DateStyle): String? {
        val oldDateStyle = getDateStyle(date)
        return StringToString(date, oldDateStyle, newDateStyle)
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param olddPattern 旧日期格式
     * @param newPattern 新日期格式
     * @return 新日期字符串
     */
    fun StringToString(date: String, olddPattern: String, newPattern: String): String? {
        return DateToString(stringToDate(date, olddPattern), newPattern)
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param olddDteStyle 旧日期风格
     * @param newParttern 新日期格式
     * @return 新日期字符串
     */
    fun StringToString(date: String, olddDteStyle: DateStyle?, newParttern: String): String? {
        var dateString: String? = null
        if (olddDteStyle != null) {
            dateString = StringToString(date, olddDteStyle.value, newParttern)
        }
        return dateString
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param olddPattern 旧日期格式
     * @param newDateStyle 新日期风格
     * @return 新日期字符串
     */
    fun StringToString(date: String, olddPattern: String, newDateStyle: DateStyle?): String? {
        var dateString: String? = null
        if (newDateStyle != null) {
            dateString = StringToString(date, olddPattern, newDateStyle.value)
        }
        return dateString
    }
 
    /**
     * 将日期字符串转化为另一日期字符串。失败返回null。
     * @param date 旧日期字符串
     * @param olddDteStyle 旧日期风格
     * @param newDateStyle 新日期风格
     * @return 新日期字符串
     */
    fun StringToString(date: String, olddDteStyle: DateStyle?, newDateStyle: DateStyle?): String? {
        var dateString: String? = null
        if (olddDteStyle != null && newDateStyle != null) {
            dateString = StringToString(date, olddDteStyle.value, newDateStyle.value)
        }
        return dateString
    }
 
    /**
     * 增加日期的年份。失败返回null。
     * @param date 日期
     * @param yearAmount 增加数量。可为负数
     * @return 增加年份后的日期字符串
     */
    fun addYear(date: String, yearAmount: Int): String? {
        return addInteger(date, Calendar.YEAR, yearAmount)
    }
 
    /**
     * 增加日期的年份。失败返回null。
     * @param date 日期
     * @param yearAmount 增加数量。可为负数
     * @return 增加年份后的日期
     */
    fun addYear(date: Date, yearAmount: Int): Date? {
        return addInteger(date, Calendar.YEAR, yearAmount)
    }
 
    /**
     * 增加日期的月份。失败返回null。
     * @param date 日期
     * @param monthAmount 增加数量。可为负数
     * @return 增加月份后的日期字符串
     */
    fun addMonth(date: String, monthAmount: Int): String? {
        return addInteger(date, Calendar.MONTH, monthAmount)
    }
 
    /**
     * 增加日期的月份。失败返回null。
     * @param date 日期
     * @param monthAmount 增加数量。可为负数
     * @return 增加月份后的日期
     */
    fun addMonth(date: Date, monthAmount: Int): Date? {
        return addInteger(date, Calendar.MONTH, monthAmount)
    }
 
    /**
     * 增加日期的天数。失败返回null。
     * @param date 日期字符串
     * @param dayAmount 增加数量。可为负数
     * @return 增加天数后的日期字符串
     */
    fun addDay(date: String, dayAmount: Int): String? {
        return addInteger(date, Calendar.DATE, dayAmount)
    }
 
    /**
     * 增加日期的天数。失败返回null。
     * @param date 日期
     * @param dayAmount 增加数量。可为负数
     * @return 增加天数后的日期
     */
    fun addDay(date: Date, dayAmount: Int): Date? {
        return addInteger(date, Calendar.DATE, dayAmount)
    }
 
    /**
     * 增加日期的小时。失败返回null。
     * @param date 日期字符串
     * @param hourAmount 增加数量。可为负数
     * @return 增加小时后的日期字符串
     */
    fun addHour(date: String, hourAmount: Int): String? {
        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount)
    }
 
    /**
     * 增加日期的小时。失败返回null。
     * @param date 日期
     * @param hourAmount 增加数量。可为负数
     * @return 增加小时后的日期
     */
    fun addHour(date: Date, hourAmount: Int): Date? {
        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount)
    }
 
    /**
     * 增加日期的分钟。失败返回null。
     * @param date 日期字符串
     * @param minuteAmount 增加数量。可为负数
     * @return 增加分钟后的日期字符串
     */
    fun addMinute(date: String, minuteAmount: Int): String? {
        return addInteger(date, Calendar.MINUTE, minuteAmount)
    }
 
    /**
     * 增加日期的分钟。失败返回null。
     * @param date 日期
     * @param minuteAmount 增加数量。可为负数
     * @return 增加分钟后的日期
     */
    fun addMinute(date: Date, minuteAmount: Int): Date? {
        return addInteger(date, Calendar.MINUTE, minuteAmount)
    }
 
    /**
     * 增加日期的秒钟。失败返回null。
     * @param date 日期字符串
     * @param secondAmount 增加数量。可为负数
     * @return 增加秒钟后的日期字符串
     */
    fun addSecond(date: String, secondAmount: Int): String? {
        return addInteger(date, Calendar.SECOND, secondAmount)
    }
 
    /**
     * 增加日期的秒钟。失败返回null。
     * @param date 日期
     * @param secondAmount 增加数量。可为负数
     * @return 增加秒钟后的日期
     */
    fun addSecond(date: Date, secondAmount: Int): Date? {
        return addInteger(date, Calendar.SECOND, secondAmount)
    }
 
    /**
     * 获取日期的年份。失败返回0。
     * @param date 日期字符串
     * @return 年份
     */
    fun getYear(date: String): Int {
        return getYear(stringToDate(date))
    }
 
    /**
     * 获取日期的年份。失败返回0。
     * @param date 日期
     * @return 年份
     */
    fun getYear(date: Date?): Int {
        return getInteger(date, Calendar.YEAR)
    }
 
    /**
     * 获取日期的月份。失败返回0。
     * @param date 日期字符串
     * @return 月份
     */
    fun getMonth(date: String): Int {
        return getMonth(stringToDate(date))
    }
 
    /**
     * 获取日期的月份。失败返回0。
     * @param date 日期
     * @return 月份
     */
    fun getMonth(date: Date?): Int {
        return getInteger(date, Calendar.MONTH) + 1
    }
 
    /**
     * 获取日期的天数。失败返回0。
     * @param date 日期字符串
     * @return 天
     */
    fun getDay(date: String): Int {
        return getDay(stringToDate(date))
    }
 
    /**
     * 获取日期的天数。失败返回0。
     * @param date 日期
     * @return 天
     */
    fun getDay(date: Date?): Int {
        return getInteger(date, Calendar.DATE)
    }
 
    /**
     * 获取日期的小时。失败返回0。
     * @param date 日期字符串
     * @return 小时
     */
    fun getHour(date: String): Int {
        return getHour(stringToDate(date))
    }
 
    /**
     * 获取日期的小时。失败返回0。
     * @param date 日期
     * @return 小时
     */
    fun getHour(date: Date?): Int {
        return getInteger(date, Calendar.HOUR_OF_DAY)
    }
 
    /**
     * 获取日期的分钟。失败返回0。
     * @param date 日期字符串
     * @return 分钟
     */
    fun getMinute(date: String): Int {
        return getMinute(stringToDate(date))
    }
 
    /**
     * 获取日期的分钟。失败返回0。
     * @param date 日期
     * @return 分钟
     */
    fun getMinute(date: Date?): Int {
        return getInteger(date, Calendar.MINUTE)
    }
 
    /**
     * 获取日期的秒钟。失败返回0。
     * @param date 日期字符串
     * @return 秒钟
     */
    fun getSecond(date: String): Int {
        return getSecond(stringToDate(date))
    }
 
    /**
     * 获取日期的秒钟。失败返回0。
     * @param date 日期
     * @return 秒钟
     */
    fun getSecond(date: Date?): Int {
        return getInteger(date, Calendar.SECOND)
    }
 
    /**
     * 获取日期 。默认yyyy-MM-dd格式。失败返回null。
     * @param date 日期字符串
     * @return 日期
     */
    fun getDate(date: String): String? {
        return StringToString(date, DateStyle.YYYY_MM_DD)
    }
 
    /**
     * 获取日期。默认yyyy-MM-dd格式。失败返回null。
     * @param date 日期
     * @return 日期
     */
    fun getDate(date: Date?): String? {
        return DateToString(date, DateStyle.YYYY_MM_DD)
    }
 
    /**
     * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
     * @param date 日期字符串
     * @return 时间
     */
    fun getTime(date: String): String? {
        return StringToString(date, DateStyle.HH_MM_SS)
    }
 
    /**
     * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
     * @param date 日期
     * @return 时间
     */
    fun getTime(date: Date): String? {
        return DateToString(date, DateStyle.HH_MM_SS)
    }
 
    /**
     * 获取日期的星期。失败返回null。
     * @param date 日期字符串
     * @return 星期
     */
    fun getWeek(date: String): Week? {
        var week: Week? = null
        val dateStyle = getDateStyle(date)
        if (dateStyle != null) {
            val myDate = stringToDate(date, dateStyle)
            week = getWeek(myDate)
        }
        return week
    }
 
    /**
     * 获取日期的星期。失败返回null。
     * @param date 日期
     * @return 星期
     */
    fun getWeek(date: Date?): Week? {
        var week: Week? = null
        val calendar = Calendar.getInstance()
        calendar.time = date!!
        val weekNumber = calendar.get(Calendar.DAY_OF_WEEK) - 1
        when (weekNumber) {
            0 -> week = Week.SUNDAY
            1 -> week = Week.MONDAY
            2 -> week = Week.TUESDAY
            3 -> week = Week.WEDNESDAY
            4 -> week = Week.THURSDAY
            5 -> week = Week.FRIDAY
            6 -> week = Week.SATURDAY
        }
        return week
    }
 
    /**
     * 获取两个日期相差的天数
     * @param date 日期字符串
     * @param otherDate 另一个日期字符串
     * @return 相差天数。如果失败则返回-1
     */
    fun getIntervalDays(date: String, otherDate: String): Int {
        return getIntervalDays(stringToDate(date), stringToDate(otherDate))
    }
 
    /**
     * @param date 日期
     * @param otherDate 另一个日期
     * @return 相差天数。如果失败则返回-1
     */
    fun getIntervalDays(date: Date?, otherDate: Date?): Int {
        var num = -1
        val dateTmp = stringToDate(getDate(date), DateStyle.YYYY_MM_DD)
        val otherDateTmp = stringToDate(getDate(otherDate), DateStyle.YYYY_MM_DD)
        if (dateTmp != null && otherDateTmp != null) {
            val time = Math.abs(dateTmp.time - otherDateTmp.time)
            num = (time / (24 * 60 * 60 * 1000)).toInt()
        }
        return num
    }
 
    /**
     * 按给定的月份以及周期,得出当前月份所在周期的开始月(例,一年以季度分为4段时间,即周期为3月,则5月所在周期开始月为4月)
     */
    fun getStartMonthByPeriod(currentMon: Int, period: Int):Int? {
        return if (period in 1..12 && currentMon in 1..12) {
            val m = currentMon % period
            val r = currentMon / period
            period * r + if (m == 0) 1 - period else 1
//            period * r + if (m == 0) 2 - period else 2
        } else {
            null
        }
    }
 
    /**
     * 根据给定的周期,返回所有可能在周期内的周期组合
     * @param period YYYY/M-M
     */
    fun getSuitablePeriod(period: String?):List<String> {
        var year:Int? = null
        var sMonth:Int? = null
        var eMonth:Int? = null
        period?.split("/")?.takeIf { it.size == 2 }?.let { p ->
            year = p[0].toIntOrNull()
            p[1].split("-").takeIf { it.size == 2 }?.let { m->
                sMonth = m[0].toIntOrNull()
                eMonth = m[1].toIntOrNull()
            }
        }
        val result = mutableListOf<String>()
        if (year != null && sMonth != null && eMonth != null) {
            repeat(eMonth!! - sMonth!! + 1) {
                result.add("${year}/${sMonth}-${sMonth}")
            }
            if (sMonth != eMonth) period?.let { result.add(it) }
        }
        return  result
    }
 
    enum class DateStyle private constructor(val value: String, val isShowOnly: Boolean) {
 
        YYYYMMDD("yyyyMMdd", false),
 
        YYYY_MM("yyyy-MM", false),
        YYYY_MM_DD("yyyy-MM-dd", false),
        YYYY_MM_DD_HH("yyyyMMddHH", false),
        YYYY_MM_DD_HH_MM("yyyy-MM-dd HH:mm", false),
        YYYY_MM_DD_HH_MM_SS("yyyy-MM-dd HH:mm:ss", false),
 
        YYYY_MM_EN("yyyy/MM", false),
        YYYY_MM_DD_EN("yyyy/MM/dd", false),
        YYYY_MM_DD_HH_MM_EN("yyyy/MM/dd HH:mm", false),
        YYYY_MM_DD_HH_MM_SS_EN("yyyy/MM/dd HH:mm:ss", false),
 
        YYYY_MM_CN("yyyy年MM月", false),
        YYYY_MM_DD_CN("yyyy年MM月dd日", false),
        YYYY_MM_DD_HH_MM_CN("yyyy年MM月dd日 HH:mm", false),
        YYYY_MM_DD_HH_MM_SS_CN("yyyy年MM月dd日 HH:mm:ss", false),
 
        HH_MM("HH:mm", true),
        HH_MM_SS("HH:mm:ss", true),
 
        MM_DD("MM-dd", true),
        MM_DD_HH_MM("MM-dd HH:mm", true),
        MM_DD_HH_MM_SS("MM-dd HH:mm:ss", true),
 
        MM_DD_EN("MM/dd", true),
        MM_DD_HH_MM_EN("MM/dd HH:mm", true),
        MM_DD_HH_MM_SS_EN("MM/dd HH:mm:ss", true),
 
        MM_DD_CN("MM月dd日", true),
        MM_DD_HH_MM_CN("MM月dd日 HH:mm", true),
        MM_DD_HH_MM_SS_CN("MM月dd日 HH:mm:ss", true)
    }
 
    enum class Week private constructor(name_cn: String, name_en: String, name_enShort: String, number: Int) {
 
        MONDAY("星期一", "Monday", "Mon.", 1),
        TUESDAY("星期二", "Tuesday", "Tues.", 2),
        WEDNESDAY("星期三", "Wednesday", "Wed.", 3),
        THURSDAY("星期四", "Thursday", "Thur.", 4),
        FRIDAY("星期五", "Friday", "Fri.", 5),
        SATURDAY("星期六", "Saturday", "Sat.", 6),
        SUNDAY("星期日", "Sunday", "Sun.", 7);
 
        var chineseName: String
            internal set
        var aname: String
            internal set
        var shortName: String
            internal set
        var number: Int = 0
            internal set
 
        init {
            this.chineseName = name_cn
            this.aname = name_en
            this.shortName = name_enShort
            this.number = number
        }
    }
}