@kne/fastify-task 3.0.0-alpha.10 → 3.0.0-alpha.11

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.
@@ -43,6 +43,13 @@ const getHour = (date, tz) => {
43
43
  return d.hour();
44
44
  };
45
45
 
46
+ const getZonedChannelHour = (periodTime, serverHour, tz) => {
47
+ if (!tz) return { date: formatDate(periodTime), hour: serverHour };
48
+ const localPeriodTime = dayjs(periodTime).hour(serverHour).minute(0).second(0).millisecond(0);
49
+ const zonedTime = localPeriodTime.tz(tz);
50
+ return { date: zonedTime.format('YYYY-MM-DD'), hour: zonedTime.hour() };
51
+ };
52
+
46
53
  const safeNum = v => {
47
54
  const n = Number(v);
48
55
  return (typeof n === 'number' && !isNaN(n) ? n : 0);
@@ -333,10 +340,10 @@ const queryHourlyChildChannels = async (statisticsServices, { channels, startTim
333
340
 
334
341
  const sum = getSumData(item);
335
342
  const count = safeNum(sum.total);
336
- const date = formatDate(item.time, tz);
343
+ const { date, hour } = getZonedChannelHour(item.time, completedHour, tz);
337
344
  mergeHourlyItem(result, {
338
345
  date,
339
- hour: completedHour,
346
+ hour,
340
347
  typeName,
341
348
  runnerTypeName,
342
349
  count,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-task",
3
- "version": "3.0.0-alpha.10",
3
+ "version": "3.0.0-alpha.11",
4
4
  "description": "一个 Fastify 插件,用于任务编排、追踪任务执行状态和结果。支持系统自动执行和手动执行两种模式,提供完整的任务生命周期管理",
5
5
  "main": "index.js",
6
6
  "scripts": {