From c8f0352ffb00e708907f53aa5229fbdf5abc6227 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 4 Oct 2025 09:57:46 +0800 Subject: [PATCH] fix: Display timestamps in user's local timezone in installation scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert UTC timestamps to local timezone in install-remote.ps1 - Convert UTC timestamps to local timezone in install-remote.sh - Support cross-platform date conversion (GNU date and BSD date) - Remove 'UTC' suffix from timestamp displays 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/prompt-templates/plan.md | 7 ------- install-remote.ps1 | 12 ++++++------ install-remote.sh | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.claude/prompt-templates/plan.md b/.claude/prompt-templates/plan.md index 8f276043..76e51103 100644 --- a/.claude/prompt-templates/plan.md +++ b/.claude/prompt-templates/plan.md @@ -1,10 +1,3 @@ ---- -name: plan -description: 软件架构规划和技术实现计划分析模板 -category: planning -keywords: [规划, 架构, 实现计划, 技术设计, 修改方案] ---- - # 软件架构规划模板 # AI Persona & Core Mission diff --git a/install-remote.ps1 b/install-remote.ps1 index 6c07484c..df450c68 100644 --- a/install-remote.ps1 +++ b/install-remote.ps1 @@ -416,10 +416,10 @@ function Get-UserVersionChoice { $response = Invoke-RestMethod -Uri $apiUrl -UseBasicParsing -TimeoutSec 5 $latestVersion = $response.tag_name - # Parse and format release date + # Parse and format release date to local time if ($response.published_at) { - $publishDate = [DateTime]::Parse($response.published_at) - $latestStableDate = $publishDate.ToString("yyyy-MM-dd HH:mm UTC") + $publishDate = [DateTime]::Parse($response.published_at).ToLocalTime() + $latestStableDate = $publishDate.ToString("yyyy-MM-dd HH:mm") } Write-ColorOutput "Latest stable: $latestVersion ($latestStableDate)" $ColorSuccess @@ -433,10 +433,10 @@ function Get-UserVersionChoice { $commitResponse = Invoke-RestMethod -Uri $commitUrl -UseBasicParsing -TimeoutSec 5 $latestCommitId = $commitResponse.sha.Substring(0, 7) - # Parse and format commit date + # Parse and format commit date to local time if ($commitResponse.commit.committer.date) { - $commitDate = [DateTime]::Parse($commitResponse.commit.committer.date) - $latestCommitDate = $commitDate.ToString("yyyy-MM-dd HH:mm UTC") + $commitDate = [DateTime]::Parse($commitResponse.commit.committer.date).ToLocalTime() + $latestCommitDate = $commitDate.ToString("yyyy-MM-dd HH:mm") } Write-ColorOutput "Latest commit: $latestCommitId ($latestCommitDate)" $ColorSuccess diff --git a/install-remote.sh b/install-remote.sh index 32349da4..902852f6 100644 --- a/install-remote.sh +++ b/install-remote.sh @@ -452,14 +452,19 @@ function get_user_version_choice() { latest_version=$(echo "$release_data" | jq -r '.tag_name' 2>/dev/null) local published_at=$(echo "$release_data" | jq -r '.published_at' 2>/dev/null) if [ -n "$published_at" ] && [ "$published_at" != "null" ]; then - # Format: 2025-10-02T04:27:21Z -> 2025-10-02 04:27 UTC - latest_date=$(echo "$published_at" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1) + # Convert UTC to local time + if command -v date &> /dev/null; then + latest_date=$(date -d "$published_at" '+%Y-%m-%d %H:%M' 2>/dev/null || date -jf '%Y-%m-%dT%H:%M:%SZ' "$published_at" '+%Y-%m-%d %H:%M' 2>/dev/null) + fi fi else latest_version=$(echo "$release_data" | grep -o '"tag_name":\s*"[^"]*"' | sed 's/"tag_name":\s*"\([^"]*\)"/\1/') local published_at=$(echo "$release_data" | grep -o '"published_at":\s*"[^"]*"' | sed 's/"published_at":\s*"\([^"]*\)"/\1/') if [ -n "$published_at" ]; then - latest_date=$(echo "$published_at" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1) + # Convert UTC to local time + if command -v date &> /dev/null; then + latest_date=$(date -d "$published_at" '+%Y-%m-%d %H:%M' 2>/dev/null || date -jf '%Y-%m-%dT%H:%M:%SZ' "$published_at" '+%Y-%m-%d %H:%M' 2>/dev/null) + fi fi fi fi @@ -480,13 +485,19 @@ function get_user_version_choice() { commit_id=$(echo "$commit_data" | jq -r '.sha' 2>/dev/null | cut -c1-7) local committer_date=$(echo "$commit_data" | jq -r '.commit.committer.date' 2>/dev/null) if [ -n "$committer_date" ] && [ "$committer_date" != "null" ]; then - commit_date=$(echo "$committer_date" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1) + # Convert UTC to local time + if command -v date &> /dev/null; then + commit_date=$(date -d "$committer_date" '+%Y-%m-%d %H:%M' 2>/dev/null || date -jf '%Y-%m-%dT%H:%M:%SZ' "$committer_date" '+%Y-%m-%d %H:%M' 2>/dev/null) + fi fi else commit_id=$(echo "$commit_data" | grep -o '"sha":\s*"[^"]*"' | head -1 | sed 's/"sha":\s*"\([^"]*\)"/\1/' | cut -c1-7) local committer_date=$(echo "$commit_data" | grep -o '"date":\s*"[^"]*"' | head -1 | sed 's/"date":\s*"\([^"]*\)"/\1/') if [ -n "$committer_date" ]; then - commit_date=$(echo "$committer_date" | sed 's/T/ /' | sed 's/Z/ UTC/' | cut -d'.' -f1) + # Convert UTC to local time + if command -v date &> /dev/null; then + commit_date=$(date -d "$committer_date" '+%Y-%m-%d %H:%M' 2>/dev/null || date -jf '%Y-%m-%dT%H:%M:%SZ' "$committer_date" '+%Y-%m-%d %H:%M' 2>/dev/null) + fi fi fi fi