feat: 统一全链路时区为 UTC+8 (Asia/Shanghai)
Deploy to Server / deploy (push) Successful in 1m36s

- schema.sql created_at DEFAULT 改为 datetime(now,+8 hours)
- Dockerfile runtime 安装 tzdata ENV TZ=Asia/Shanghai 并软链 /etc/localtime
- docker-compose.yml 挂载宿主机 localtime 并传 TZ=Asia/Shanghai
- server index.ts 入口设置 process.env.TZ
- client utils/export 新增 utc8Now/utc8Input/utc8DateStamp/utc8DateTimeStamp
- Activities 默认活动开始/结束时间改用 UTC+8
- 导出文件名日期戳和报告生成时间统一 utc8DateStamp/utc8DateTimeStamp
This commit is contained in:
Trae Assistant
2026-10-05 09:09:01 +08:00
parent 7f9bf15b7d
commit 30021d7b46
8 changed files with 53 additions and 18 deletions
+3 -3
View File
@@ -27,7 +27,7 @@ CREATE TABLE IF NOT EXISTS activities (
content TEXT,
start_time TEXT NOT NULL,
end_time TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
created_at TEXT NOT NULL DEFAULT (datetime('now','+8 hours'))
);
CREATE TABLE IF NOT EXISTS activity_groups (
@@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS hours (
user_id INTEGER NOT NULL,
hours REAL NOT NULL DEFAULT 0,
remark TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime')),
created_at TEXT NOT NULL DEFAULT (datetime('now','+8 hours')),
FOREIGN KEY (activity_id) REFERENCES activities(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
UNIQUE(activity_id, user_id)
@@ -54,5 +54,5 @@ CREATE TABLE IF NOT EXISTS admins (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
created_at TEXT NOT NULL DEFAULT (datetime('now','+8 hours'))
);
+2
View File
@@ -10,6 +10,8 @@ import activitiesRoutes from './routes/activities';
import hoursRoutes from './routes/hours';
import exportRoutes from './routes/export';
process.env.TZ = 'Asia/Shanghai';
async function bootstrap() {
await initDb();
const app = express();