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

Đang mở
#306 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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).
Ngôn ngữ chính
TypeScript
Star
277
Fork
27
Merge trung bình
7 giờ 8 phút
Pull request đã merge (30 ngày)
81

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DuskBotAI/duskbot

Tất cả issue của DuskBotAI/duskbot

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.