time zone: a self-hosted server can tell time in its owner's zone, the way a Cloud home does

未关闭
#306 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
api, backend

调研方向

The first read is createTimeZoneRoutes, where adopts is false outside Cloud homes; trace its callers and the Cloud path through useTimeZone, adoptSavedTimeZone and time-zone.json. Also find how serve --public-url chooses host mode and where TZ is read, because self-hosted must adopt while TZ wins and desktops stay unchanged. Done means PUT /api/time-zone succeeds on a self-hosted server, the saved zone drives routines and bot time, and the host-detection question is settled.

由索引模型根据 Issue 内容生成。

描述

The problem

I run dusk bot on my own VPS (duskbot serve --public-url ...). The VPS clock is UTC, like most servers, but I live in Asia/Kolkata (UTC+5:30).

Only a Cloud home adopts its owner's zone. createTimeZoneRoutes gets adopts: false everywhere else, so PUT /api/time-zone answers 409 "This computer tells time in its own time zone." On a desktop that is right: the computer's clock is the person's. On a VPS it is not.

What goes wrong today:

  • A daily routine at 18:00 runs at 23:30 my time.
  • An interval routine "every 15 min, Mon-Fri, 09:00-18:00" runs from 14:30 to 23:30 my time. Its window and its weekdays both follow the UTC clock.
  • When I ask a bot "remind me every day at 6 PM", it can make a daily routine, and that fires at 23:30.
  • The bots' "current time" and run titles are in UTC.

cron routines with an explicit timeZone are fine, so I create everything as cron for now. But anything made by chatting, or in the routine editor with daily or interval, comes out wrong.

The only fix today is Environment=TZ=Asia/Kolkata in the systemd unit. That works, but nothing in the app says it is needed, and it does not follow me when I travel the way a Cloud home does.

What you'd like

Let a self-hosted server adopt its owner's zone with the same code path a Cloud home uses (useTimeZone, adoptSavedTimeZone, time-zone.json).

  • On a self-hosted server (not a desktop), adopts is true, so the owner's app sends its zone and the server saves it and runs in it.
  • If TZ is set in the server's environment, that wins, so people who already set it see no change.
  • A desktop keeps today's rule: its own clock.
Anything else
  • I checked the timing with dusk bot's own schedule code: with the server on UTC, the interval example above runs 5.5 hours late; with TZ=Asia/Kolkata it matches.
  • I'm happy to send the PR if this shape works for you. The open question for you is how the server should know it is self-hosted and not a desktop (for example serve with --public-url, or a flag).
主要语言
TypeScript
星标
277
派生
27
平均合并
7 小时 8 分钟
30 天内合并 PR
81

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DuskBotAI/duskbot 的其他 Issue

查看 DuskBotAI/duskbot 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。