lyb-js 1.6.25 → 1.6.26

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/README.md CHANGED
@@ -177,6 +177,8 @@ console.log(t); //"string"
177
177
 
178
178
  \- [LibJsTimeGreeting-时间问候](#LibJsTimeGreeting-时间问候)
179
179
 
180
+ \- [LibJsCountdown-倒计时](#LibJsCountdown-倒计时)
181
+
180
182
 
181
183
  ## Base-基础
182
184
 
@@ -784,7 +786,7 @@ const result3 = libJsTimeGreeting({ afternoon: "午后好" }); //自定义下午
784
786
  console.log(result3); //50% 概率为 true
785
787
  ```
786
788
 
787
- ### libJsCountdown-倒计时
789
+ ### LibJsCountdown-倒计时
788
790
 
789
791
  > 以当前时间为开始时间,传递结束时间,返回年到秒的数值,以及是否结束
790
792
 
@@ -7,12 +7,12 @@ export const libJsCountdown = (endTime) => {
7
7
  const time = dayjs.duration(diff);
8
8
  const pad = (n) => n.toString().padStart(2, "0");
9
9
  return {
10
- years: pad(time.years()),
11
- months: pad(time.months()),
12
- days: pad(time.days()),
13
- hours: pad(time.hours()),
14
- minutes: pad(time.minutes()),
15
- seconds: pad(time.seconds()),
10
+ years: diff <= 0 ? "00" : pad(time.years()),
11
+ months: diff <= 0 ? "00" : pad(time.months()),
12
+ days: diff <= 0 ? "00" : pad(time.days()),
13
+ hours: diff <= 0 ? "00" : pad(time.hours()),
14
+ minutes: diff <= 0 ? "00" : pad(time.minutes()),
15
+ seconds: diff <= 0 ? "00" : pad(time.seconds()),
16
16
  ended: diff <= 0,
17
17
  };
18
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-js",
3
- "version": "1.6.25",
3
+ "version": "1.6.26",
4
4
  "description": "自用JS方法库",
5
5
  "license": "ISC",
6
6
  "type": "module",