hsu-utils 0.0.51 → 0.0.52

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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * hsu-utils v0.0.50
3
+ * hsu-utils v0.0.51
4
4
  *
5
5
  * some front-end utils
6
6
  *
@@ -4,7 +4,7 @@ export interface GetDateRangeOptions {
4
4
  amount?: number;
5
5
  type: DateRangeType;
6
6
  baseDate?: string | Date | Dayjs;
7
- unit?: 'day' | 'week' | 'month' | 'year';
7
+ unit?: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
8
8
  minDate?: string | Date | Dayjs;
9
9
  maxDate?: string | Date | Dayjs;
10
10
  hasTime?: boolean;
@@ -31,6 +31,10 @@ function getFormat(type, unit = 'day', hasTime = false) {
31
31
  case 'month':
32
32
  baseFormat = 'YYYY-MM';
33
33
  break;
34
+ case 'second':
35
+ case 'minute':
36
+ case 'hour':
37
+ return 'YYYY-MM-DD HH:mm:ss';
34
38
  case 'week':
35
39
  case 'day':
36
40
  default:
@@ -39,7 +43,7 @@ function getFormat(type, unit = 'day', hasTime = false) {
39
43
  }
40
44
  break;
41
45
  }
42
- if (hasTime && baseFormat.includes('DD')) {
46
+ if (hasTime && baseFormat.endsWith('DD')) {
43
47
  return `${baseFormat} HH:mm:ss`;
44
48
  }
45
49
  return baseFormat;
@@ -4,7 +4,7 @@ export interface GetDateRangeOptions {
4
4
  amount?: number;
5
5
  type: DateRangeType;
6
6
  baseDate?: string | Date | Dayjs;
7
- unit?: 'day' | 'week' | 'month' | 'year';
7
+ unit?: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
8
8
  minDate?: string | Date | Dayjs;
9
9
  maxDate?: string | Date | Dayjs;
10
10
  hasTime?: boolean;
@@ -38,6 +38,10 @@ function getFormat(type, unit, hasTime) {
38
38
  case 'month':
39
39
  baseFormat = 'YYYY-MM';
40
40
  break;
41
+ case 'second':
42
+ case 'minute':
43
+ case 'hour':
44
+ return 'YYYY-MM-DD HH:mm:ss';
41
45
  case 'week':
42
46
  case 'day':
43
47
  default:
@@ -46,7 +50,7 @@ function getFormat(type, unit, hasTime) {
46
50
  }
47
51
  break;
48
52
  }
49
- if (hasTime && baseFormat.includes('DD')) {
53
+ if (hasTime && baseFormat.endsWith('DD')) {
50
54
  return "".concat(baseFormat, " HH:mm:ss");
51
55
  }
52
56
  return baseFormat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hsu-utils",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "some front-end utils",
5
5
  "repository": "git@github.com:VitaTsui/hsu-utils.git",
6
6
  "author": "VitaHsu <vitahsu7@gmail.com>",