dsh-activity-pane 0.6.0 → 0.7.0

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.
@@ -1993,12 +1993,14 @@ function buildRecent(snapshot, workspaceItems, now, detailsById = {}, archivedId
1993
1993
  return entries;
1994
1994
  }
1995
1995
 
1996
- /** 毫秒时长的人性化短格式,例如 "47s"、"3m12s"。 */
1996
+ /** 毫秒时长的人性化短格式,例如 "47s"、"3m12s"、"1h2m3s"。 */
1997
1997
  function fmtElapsedMs(ms) {
1998
1998
  if (!Number.isFinite(ms) || ms < 0) return "";
1999
1999
  const s = Math.round(ms / 1000);
2000
2000
  if (s < 60) return `${s}s`;
2001
- return `${Math.floor(s / 60)}m${s % 60}s`;
2001
+ const m = Math.floor(s / 60);
2002
+ if (m < 60) return `${m}m${s % 60}s`;
2003
+ return `${Math.floor(m / 60)}h${m % 60}m${s % 60}s`;
2002
2004
  }
2003
2005
 
2004
2006
  /** 历史卡相对活动时间:按分钟、小时、天、周、月、年分级;负值返回空。 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-activity-pane",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "packageManager": "pnpm@11.5.0",
5
5
  "engines": {
6
6
  "node": ">=20"
package/scripts/check.mjs CHANGED
@@ -1035,6 +1035,11 @@ assert.deepEqual(
1035
1035
  );
1036
1036
  assert.equal(fmtElapsedMs(47_000), "47s", "时长短格式");
1037
1037
  assert.equal(fmtElapsedMs(193_000), "3m13s", "时长分秒格式");
1038
+ // R-01-009/AC-05 超过 1 小时按时分秒显示
1039
+ assert.equal(fmtElapsedMs(3_723_000), "1h2m3s", "时长时分秒格式");
1040
+ assert.equal(fmtElapsedMs(9_772_000), "2h42m52s", "多小时格式");
1041
+ assert.equal(fmtElapsedMs(3_600_000), "1h0m0s", "整小时保留零段");
1042
+ assert.equal(fmtElapsedMs(3_599_500), "1h0m0s", "秒数四舍五入进位到小时");
1038
1043
  // R-01-009/AC-03
1039
1044
  assert.equal(fmtElapsedMs(NaN), "", "NaN 时长归一为空");
1040
1045
  assert.equal(fmtElapsedMs(Infinity), "", "Infinity 时长归一为空");
package/src/core.mjs CHANGED
@@ -1987,12 +1987,14 @@ export function buildRecent(snapshot, workspaceItems, now, detailsById = {}, arc
1987
1987
  return entries;
1988
1988
  }
1989
1989
 
1990
- /** 毫秒时长的人性化短格式,例如 "47s"、"3m12s"。 */
1990
+ /** 毫秒时长的人性化短格式,例如 "47s"、"3m12s"、"1h2m3s"。 */
1991
1991
  export function fmtElapsedMs(ms) {
1992
1992
  if (!Number.isFinite(ms) || ms < 0) return "";
1993
1993
  const s = Math.round(ms / 1000);
1994
1994
  if (s < 60) return `${s}s`;
1995
- return `${Math.floor(s / 60)}m${s % 60}s`;
1995
+ const m = Math.floor(s / 60);
1996
+ if (m < 60) return `${m}m${s % 60}s`;
1997
+ return `${Math.floor(m / 60)}h${m % 60}m${s % 60}s`;
1996
1998
  }
1997
1999
 
1998
2000
  /** 历史卡相对活动时间:按分钟、小时、天、周、月、年分级;负值返回空。 */