date, touch: parsing date’s own output in Asia/Shanghai moves the timestamp forward 14 hours

Đang mở
#16,773 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
linux, rust
Lĩnh vực
cli

Hướng nghiên cứu

Start by reproducing the report with the commands in the issue body under TZ=Asia/Shanghai and LC_ALL=C, comparing uutils date and touch against GNU output. The issue links uutils/parse_datetime#358 and #11045, so check whether the fault is in how the default date format is parsed or in the parse_datetime dependency. Done means date -d and touch -d round-trip the default output to the same instant in Asia/Shanghai, Asia/Taipei and Europe/Dublin, matching GNU.

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

Mô tả

In Asia/Shanghai, date prints local noon on June 1 and then reads that same string as 02:00 on June 2. touch -d writes the same incorrect file timestamp. Both commands exit 0.

export LC_ALL=C TZ=Asia/Shanghai
stamp=$(date -d @1717214400)
printf '%s\n' "$stamp"  # Sat Jun  1 12:00:00 CST 2024
date -d "$stamp" '+%s %F %T %z'
f=$(mktemp) && touch -d "$stamp" "$f" && date -r "$f" '+%s %F %T %z'

Both result lines on uutils: 1717264800 2024-06-02 02:00:00 +0800. On GNU: 1717214400 2024-06-01 12:00:00 +0800. Both implementations initially print the same string. Using +%F %T %z to include the numeric offset preserves the instant in both.

The default date output also shifts by +14h in Asia/Taipei and by -4h30m in Europe/Dublin for this June timestamp. Verified on x86_64 Linux with uutils 0.12.0, 0.13.0 and main at 791399596cc7214e76c0c6bd022332ab6048ec65, compared with GNU coreutils 9.7 and 9.12. Related work: #11045 and uutils/parse_datetime#358.

Ngôn ngữ chính
Rust
Star
24.4k
Fork
2.2k
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
402

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 uutils/coreutils

Tất cả issue của uutils/coreutils

Issue tương tự

Thêm issue về Rust

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.