@94ai/nf-double-quarter 100.1.1 → 100.1.5

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,61 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const vueDemi = require("vue-demi");
4
+ const commonUtils = require("@94ai/common-utils");
4
5
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
5
- function getQuarter(date = /* @__PURE__ */ new Date()) {
6
- const currMonth = date.getMonth() + 1;
7
- return Math.floor(currMonth % 3 == 0 ? currMonth / 3 : currMonth / 3 + 1);
8
- }
9
- function getNextYear(date = /* @__PURE__ */ new Date()) {
10
- return new Date(date.setFullYear(date.getFullYear() + 1));
11
- }
12
- function endOf(now = /* @__PURE__ */ new Date(), unit) {
13
- if (unit === "year") {
14
- return new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
15
- }
16
- if (unit === "month") {
17
- return new Date(new Date(now.getFullYear(), now.getMonth() + 1, 1).getTime() - 1);
18
- }
19
- if (unit === "week") {
20
- return new Date(now.getFullYear(), now.getMonth(), now.getDate() + (6 - now.getDay()), 23, 59, 59, 999);
21
- }
22
- return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
23
- }
24
- function startOf(date, unit) {
25
- const newDate = new Date(date);
26
- if (unit === "year") {
27
- newDate.setMonth(0);
28
- newDate.setDate(1);
29
- newDate.setHours(0, 0, 0, 0);
30
- } else if (unit === "month") {
31
- newDate.setDate(1);
32
- newDate.setHours(0, 0, 0, 0);
33
- } else if (unit === "") {
34
- newDate.setHours(0, 0, 0, 0);
35
- } else if (unit === "hour") {
36
- newDate.setMinutes(0, 0, 0);
37
- } else if (unit === "minute") {
38
- newDate.setSeconds(0, 0);
39
- } else if (unit === "second") {
40
- newDate.setMilliseconds(0);
41
- }
42
- return newDate;
43
- }
44
- function formatDate(date, format) {
45
- const year = date.getFullYear();
46
- const month = date.getMonth() + 1;
47
- const day = date.getDate();
48
- const hours = date.getHours();
49
- const minutes = date.getMinutes();
50
- const seconds = date.getSeconds();
51
- format = format.replace("YYYY", year);
52
- format = format.replace("MM", String(month).padStart(2, "0"));
53
- format = format.replace("DD", String(day).padStart(2, "0"));
54
- format = format.replace("HH", String(hours).padStart(2, "0"));
55
- format = format.replace("mm", String(minutes).padStart(2, "0"));
56
- format = format.replace("ss", String(seconds).padStart(2, "0"));
57
- return format;
58
- }
59
6
  const quarterOptions = [
60
7
  {
61
8
  label: "Q1",
@@ -122,7 +69,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
122
69
  const emits = __ctx.emit;
123
70
  const now = /* @__PURE__ */ new Date();
124
71
  const now_year = vueDemi.ref(now.getFullYear());
125
- const now_quarter = `${now_year.value}-${getQuarter(now)}`;
72
+ const now_quarter = `${now_year.value}-${commonUtils.getQuarter(now)}`;
126
73
  const options = vueDemi.computed(() => {
127
74
  return quarterOptions.map((item) => {
128
75
  return {
@@ -356,18 +303,18 @@ __sfc_main.setup = (__props, __ctx) => {
356
303
  if (props.value) {
357
304
  const startDate = new Date(props.value[0]);
358
305
  const endDate = new Date(props.value[1]);
359
- return [`${startDate.getFullYear()}-${getQuarter(startDate)}`, `${endDate.getFullYear()}-${getQuarter(endDate)}`];
306
+ return [`${startDate.getFullYear()}-${commonUtils.getQuarter(startDate)}`, `${endDate.getFullYear()}-${commonUtils.getQuarter(endDate)}`];
360
307
  }
361
308
  return null;
362
309
  });
363
310
  const handleOpenPicker = (instance) => {
364
311
  let startDate = /* @__PURE__ */ new Date();
365
- let endDate = getNextYear(startDate);
312
+ let endDate = commonUtils.getNextYear(startDate);
366
313
  if (props.value) {
367
314
  startDate = new Date(props.value[0]);
368
315
  endDate = new Date(props.value[1]);
369
- startQuarter.value = [`${startDate.getFullYear()}-${getQuarter(startDate)}`];
370
- endQuarter.value = [`${endDate.getFullYear()}-${getQuarter(endDate)}`];
316
+ startQuarter.value = [`${startDate.getFullYear()}-${commonUtils.getQuarter(startDate)}`];
317
+ endQuarter.value = [`${endDate.getFullYear()}-${commonUtils.getQuarter(endDate)}`];
371
318
  }
372
319
  startYear.value = startDate.getFullYear();
373
320
  endYear.value = endDate.getFullYear();
@@ -423,8 +370,8 @@ __sfc_main.setup = (__props, __ctx) => {
423
370
  if (months.length) {
424
371
  result.push({
425
372
  ...item,
426
- startDate: formatDate(startOf(new Date(item.year, months[0] - 1), "month"), "YYYY-MM-DD"),
427
- endDate: formatDate(endOf(new Date(item.year, months[months.length - 1] - 1), "month"), "YYYY-MM-DD")
373
+ startDate: commonUtils.formatDate(commonUtils.startOf(new Date(item.year, months[0] - 1), "month"), "YYYY-MM-DD"),
374
+ endDate: commonUtils.formatDate(commonUtils.endOf(new Date(item.year, months[months.length - 1] - 1), "month"), "YYYY-MM-DD")
428
375
  });
429
376
  }
430
377
  }
@@ -1,59 +1,6 @@
1
1
  import { defineComponent, ref, computed } from "vue-demi";
2
+ import { getQuarter, getNextYear, formatDate, startOf, endOf } from "@94ai/common-utils";
2
3
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
- function getQuarter(date = /* @__PURE__ */ new Date()) {
4
- const currMonth = date.getMonth() + 1;
5
- return Math.floor(currMonth % 3 == 0 ? currMonth / 3 : currMonth / 3 + 1);
6
- }
7
- function getNextYear(date = /* @__PURE__ */ new Date()) {
8
- return new Date(date.setFullYear(date.getFullYear() + 1));
9
- }
10
- function endOf(now = /* @__PURE__ */ new Date(), unit) {
11
- if (unit === "year") {
12
- return new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
13
- }
14
- if (unit === "month") {
15
- return new Date(new Date(now.getFullYear(), now.getMonth() + 1, 1).getTime() - 1);
16
- }
17
- if (unit === "week") {
18
- return new Date(now.getFullYear(), now.getMonth(), now.getDate() + (6 - now.getDay()), 23, 59, 59, 999);
19
- }
20
- return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
21
- }
22
- function startOf(date, unit) {
23
- const newDate = new Date(date);
24
- if (unit === "year") {
25
- newDate.setMonth(0);
26
- newDate.setDate(1);
27
- newDate.setHours(0, 0, 0, 0);
28
- } else if (unit === "month") {
29
- newDate.setDate(1);
30
- newDate.setHours(0, 0, 0, 0);
31
- } else if (unit === "") {
32
- newDate.setHours(0, 0, 0, 0);
33
- } else if (unit === "hour") {
34
- newDate.setMinutes(0, 0, 0);
35
- } else if (unit === "minute") {
36
- newDate.setSeconds(0, 0);
37
- } else if (unit === "second") {
38
- newDate.setMilliseconds(0);
39
- }
40
- return newDate;
41
- }
42
- function formatDate(date, format) {
43
- const year = date.getFullYear();
44
- const month = date.getMonth() + 1;
45
- const day = date.getDate();
46
- const hours = date.getHours();
47
- const minutes = date.getMinutes();
48
- const seconds = date.getSeconds();
49
- format = format.replace("YYYY", year);
50
- format = format.replace("MM", String(month).padStart(2, "0"));
51
- format = format.replace("DD", String(day).padStart(2, "0"));
52
- format = format.replace("HH", String(hours).padStart(2, "0"));
53
- format = format.replace("mm", String(minutes).padStart(2, "0"));
54
- format = format.replace("ss", String(seconds).padStart(2, "0"));
55
- return format;
56
- }
57
4
  const quarterOptions = [
58
5
  {
59
6
  label: "Q1",
@@ -75,7 +75,7 @@ import {
75
75
  getNextYear,
76
76
  getQuarter,
77
77
  startOf
78
- } from './util'
78
+ } from '@94ai/common-utils'
79
79
  import { getQuarterOptionMonths } from './config'
80
80
  import { QuarterItem } from './types'
81
81
 
@@ -44,7 +44,7 @@ import {
44
44
  defineProps,
45
45
  ref
46
46
  } from 'vue-demi'
47
- import { getQuarter } from './util'
47
+ import { getQuarter } from '@94ai/common-utils'
48
48
  import { quarterOptions } from './config'
49
49
  import { QuarterItem } from './types'
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-double-quarter",
3
- "version": "100.1.1",
3
+ "version": "100.1.5",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,7 +14,8 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^100.1.1",
17
+ "@94ai/common-utils": "^100.1.5",
18
+ "@94ai/nf-theme-chalk": "^100.1.5",
18
19
  "vue-demi": "^0.14.5"
19
20
  },
20
21
  "peerDependenciesMeta": {
@@ -28,7 +29,7 @@
28
29
  "vue": "^2.0.0 || >=3.0.0"
29
30
  },
30
31
  "types": "lib/index.d.ts",
31
- "main": "lib/nf-double-quarter.cjs.js",
32
- "module": "lib/nf-double-quarter.esm-bundler.js",
33
- "gitHead": "b039d7cd2dc96d3caa84a60da9f0b5f68f9572e5"
32
+ "main": "lib/nf-double-quarter.cjs.cjs",
33
+ "module": "lib/nf-double-quarter.esm-bundler.mjs",
34
+ "gitHead": "5b811c0e9d5ed95519222e3a9b744331734feeaf"
34
35
  }
package/lib/util.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare function getQuarter(date?: Date): number;
2
- export declare function getNextYear(date?: Date): Date;
3
- export declare function endOf(now: Date | undefined, unit: any): Date;
4
- export declare function startOf(date: any, unit: any): Date;
5
- export declare function formatDate(date: any, format: any): any;
package/package/util.ts DELETED
@@ -1,56 +0,0 @@
1
- export function getQuarter(date = new Date()) {
2
- const currMonth = date.getMonth() + 1
3
- return Math.floor((currMonth % 3 == 0 ? (currMonth / 3) : (currMonth / 3 + 1)))
4
- }
5
- export function getNextYear(date = new Date()) {
6
- return new Date(date.setFullYear(date.getFullYear() + 1))
7
- }
8
- export function endOf(now = new Date(), unit) {
9
- if (unit === 'year') {
10
- return new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999);
11
- }
12
- if (unit === 'month') {
13
- return new Date(new Date(now.getFullYear(), now.getMonth() + 1, 1).getTime() - 1);
14
- }
15
- if (unit === 'week') {
16
- return new Date(now.getFullYear(), now.getMonth(), now.getDate() + (6 - now.getDay()), 23, 59, 59, 999);
17
- }
18
- return new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59, 999);
19
- }
20
-
21
- export function startOf(date, unit) {
22
- const newDate = new Date(date)
23
- if (unit === 'year') {
24
- newDate.setMonth(0)
25
- newDate.setDate(1)
26
- newDate.setHours(0, 0, 0, 0)
27
- } else if (unit === 'month') {
28
- newDate.setDate(1)
29
- newDate.setHours(0, 0, 0, 0)
30
- } else if (unit === '') {
31
- newDate.setHours(0, 0, 0, 0)
32
- } else if (unit === 'hour') {
33
- newDate.setMinutes(0, 0, 0)
34
- } else if (unit === 'minute') {
35
- newDate.setSeconds(0, 0)
36
- } else if (unit === 'second') {
37
- newDate.setMilliseconds(0)
38
- }
39
- return newDate
40
- }
41
-
42
- export function formatDate(date, format) {
43
- const year = date.getFullYear()
44
- const month = date.getMonth() + 1
45
- const day = date.getDate()
46
- const hours = date.getHours()
47
- const minutes = date.getMinutes()
48
- const seconds = date.getSeconds()
49
- format = format.replace('YYYY', year)
50
- format = format.replace('MM', String(month).padStart(2, '0'))
51
- format = format.replace('DD', String(day).padStart(2, '0'))
52
- format = format.replace('HH', String(hours).padStart(2, '0'))
53
- format = format.replace('mm', String(minutes).padStart(2, '0'))
54
- format = format.replace('ss', String(seconds).padStart(2, '0'))
55
- return format
56
- }