zzz-pc-view 0.0.34 → 0.0.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zzz-pc-view",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "main": "src/index.umd.js",
5
5
  "module": "src/index.es.js",
6
6
  "types": "src/index.d.ts",
package/src/index.es.js CHANGED
@@ -956,6 +956,7 @@ class ZDate extends Date {
956
956
  *
957
957
  * @param beginTime - 开始时间,可以是字符串、数字、Date 对象或 ZDate 对象。
958
958
  * @param endTime - 结束时间,可以是字符串、数字、Date 对象或 ZDate 对象。
959
+ * @param diff - 误差值,最后一个单位大于diff值,则向上取整,默认为 0。
959
960
  * @param lastEndIndex - 最后一个时间单位的索引,默认为 timeConfigs 数组的最后一个索引。
960
961
  * @returns 持续时间的格式字符串。
961
962
  *
@@ -977,7 +978,7 @@ class ZDate extends Date {
977
978
  const durationStr = ZUtils.ZDate.getDurationFormatStr(beginTime, endTime, -1)
978
979
  console.log(durationStr)
979
980
  */
980
- static getDurationFormatStr(beginTime, endTime, lastEndIndex = lastTimeConfigsIndex) {
981
+ static getDurationFormatStr(beginTime, endTime, diff = 0, lastEndIndex = lastTimeConfigsIndex) {
981
982
  const results = [];
982
983
  lastEndIndex = Math.max(
983
984
  0,
@@ -1004,16 +1005,18 @@ class ZDate extends Date {
1004
1005
  }
1005
1006
  const lastResultsIndex = results.length - 1;
1006
1007
  const lastResult = results[lastResultsIndex];
1007
- lastResult[0] = Math.ceil(lastResult[0]);
1008
- if (lastResult[0] > lastResult[1].max) {
1009
- lastResult[0] = 0;
1010
- for (let i = lastResultsIndex - 1; i >= 0; i--) {
1011
- const result = results[i];
1012
- result[0] = Math.floor(result[0]) + 1;
1013
- if (result[0] > result[1].max) {
1014
- result[0] = 0;
1015
- } else {
1016
- break;
1008
+ if (lastResult[0] > diff) {
1009
+ lastResult[0] = Math.ceil(lastResult[0]);
1010
+ if (lastResult[0] > lastResult[1].max) {
1011
+ lastResult[0] = 0;
1012
+ for (let i = lastResultsIndex - 1; i >= 0; i--) {
1013
+ const result = results[i];
1014
+ result[0] = Math.floor(result[0]) + 1;
1015
+ if (result[0] > result[1].max) {
1016
+ result[0] = 0;
1017
+ } else {
1018
+ break;
1019
+ }
1017
1020
  }
1018
1021
  }
1019
1022
  }