@polyv/utils 2.0.0-beta.2 → 2.0.0-beta.3
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.
- package/dist/cjs/date.d.ts +3 -3
- package/dist/cjs/date.js +1 -1
- package/dist/es/date.d.ts +3 -3
- package/dist/es/date.js +1 -1
- package/package.json +1 -1
package/dist/cjs/date.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface FormatSecondsOptions {
|
|
|
20
20
|
/**
|
|
21
21
|
* 段数,2 或者 3。
|
|
22
22
|
* 为 3 时,格式化样式为「时:分:秒」。
|
|
23
|
-
* 为 2
|
|
23
|
+
* 为 2 时,格式化样式为「分:秒」。
|
|
24
24
|
*/
|
|
25
25
|
segments?: number;
|
|
26
26
|
/**
|
|
@@ -35,10 +35,10 @@ export interface FormatSecondsOptions {
|
|
|
35
35
|
* @return 格式化结果。
|
|
36
36
|
* @example
|
|
37
37
|
* ```javascript
|
|
38
|
-
* formatSeconds(3682); // '
|
|
38
|
+
* formatSeconds(3682); // '61:22'
|
|
39
39
|
* formatSeconds(82); // '01:22'
|
|
40
40
|
* formatSeconds(82, { segments: 3 }); // '00:01:22'
|
|
41
|
-
* formatSeconds(3682, { digits: 1 }); // '1:1:22'
|
|
41
|
+
* formatSeconds(3682, { segments: 3, digits: 1 }); // '1:1:22'
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
export declare function formatSeconds(secs: number, options?: FormatSecondsOptions): string;
|
package/dist/cjs/date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function ensureDate(e){return"object"!=typeof e&&(e=new Date(e)),e}function formatDate(e,t){var r={Y:(e=ensureDate(e)).getFullYear(),M:e.getMonth()+1,D:e.getDate(),h:e.getHours(),m:e.getMinutes(),s:e.getSeconds()};return t.replace(/([YMDhms])\1*/g,(function(e){var t=r[e[0]].toString(),n=e.length;return n>t.length&&(t=new Array(n-t.length+1).join("0")+t),t}))}function formatSeconds(e,t){if(void 0===t&&(t={segments:2,digits:2}),e=Number(e),isNaN(e)||e<0)throw new Error('"secs" must be a positive integer');var r=0|(t.segments||2),n=0|(t.digits||2);n=Math.max(1,n),-1===[2,3].indexOf(r)&&(r=2);var o=new Array(n+1).join("0"),a=[
|
|
1
|
+
"use strict";function ensureDate(e){return"object"!=typeof e&&(e=new Date(e)),e}function formatDate(e,t){var r={Y:(e=ensureDate(e)).getFullYear(),M:e.getMonth()+1,D:e.getDate(),h:e.getHours(),m:e.getMinutes(),s:e.getSeconds()};return t.replace(/([YMDhms])\1*/g,(function(e){var t=r[e[0]].toString(),n=e.length;return n>t.length&&(t=new Array(n-t.length+1).join("0")+t),t}))}function formatSeconds(e,t){if(void 0===t&&(t={segments:2,digits:2}),e=Number(e),isNaN(e)||e<0)throw new Error('"secs" must be a positive integer');var r=0|(t.segments||2),n=0|(t.digits||2);n=Math.max(1,n),-1===[2,3].indexOf(r)&&(r=2);var o=new Array(n+1).join("0"),a=[60,1];return 3===t.segments&&a.unshift(3600),a.map((function(t){var r=Math.floor(e/t),a=r.toString().length;return e%=t,(o+r).slice(-Math.max(a,n))})).join(":")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatSeconds=exports.formatDate=void 0,exports.formatDate=formatDate,exports.formatSeconds=formatSeconds;
|
package/dist/es/date.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface FormatSecondsOptions {
|
|
|
20
20
|
/**
|
|
21
21
|
* 段数,2 或者 3。
|
|
22
22
|
* 为 3 时,格式化样式为「时:分:秒」。
|
|
23
|
-
* 为 2
|
|
23
|
+
* 为 2 时,格式化样式为「分:秒」。
|
|
24
24
|
*/
|
|
25
25
|
segments?: number;
|
|
26
26
|
/**
|
|
@@ -35,10 +35,10 @@ export interface FormatSecondsOptions {
|
|
|
35
35
|
* @return 格式化结果。
|
|
36
36
|
* @example
|
|
37
37
|
* ```javascript
|
|
38
|
-
* formatSeconds(3682); // '
|
|
38
|
+
* formatSeconds(3682); // '61:22'
|
|
39
39
|
* formatSeconds(82); // '01:22'
|
|
40
40
|
* formatSeconds(82, { segments: 3 }); // '00:01:22'
|
|
41
|
-
* formatSeconds(3682, { digits: 1 }); // '1:1:22'
|
|
41
|
+
* formatSeconds(3682, { segments: 3, digits: 1 }); // '1:1:22'
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
44
|
export declare function formatSeconds(secs: number, options?: FormatSecondsOptions): string;
|
package/dist/es/date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function ensureDate(t){return"object"!=typeof t&&(t=new Date(t)),t}export function formatDate(t,e){const n={Y:(t=ensureDate(t)).getFullYear(),M:t.getMonth()+1,D:t.getDate(),h:t.getHours(),m:t.getMinutes(),s:t.getSeconds()};return e.replace(/([YMDhms])\1*/g,(function(t){let e=n[t[0]].toString();const r=t.length;return r>e.length&&(e=new Array(r-e.length+1).join("0")+e),e}))}export function formatSeconds(t,e={segments:2,digits:2}){if(t=Number(t),isNaN(t)||t<0)throw new Error('"secs" must be a positive integer');let n=0|(e.segments||2),r=0|(e.digits||2);r=Math.max(1,r),-1===[2,3].indexOf(n)&&(n=2);const o=new Array(r+1).join("0"),s=[
|
|
1
|
+
function ensureDate(t){return"object"!=typeof t&&(t=new Date(t)),t}export function formatDate(t,e){const n={Y:(t=ensureDate(t)).getFullYear(),M:t.getMonth()+1,D:t.getDate(),h:t.getHours(),m:t.getMinutes(),s:t.getSeconds()};return e.replace(/([YMDhms])\1*/g,(function(t){let e=n[t[0]].toString();const r=t.length;return r>e.length&&(e=new Array(r-e.length+1).join("0")+e),e}))}export function formatSeconds(t,e={segments:2,digits:2}){if(t=Number(t),isNaN(t)||t<0)throw new Error('"secs" must be a positive integer');let n=0|(e.segments||2),r=0|(e.digits||2);r=Math.max(1,r),-1===[2,3].indexOf(n)&&(n=2);const o=new Array(r+1).join("0"),s=[60,1];return 3===e.segments&&s.unshift(3600),s.map((e=>{const n=Math.floor(t/e),s=n.toString().length;return t%=e,(o+n).slice(-Math.max(s,r))})).join(":")}
|