Datetime with a time zone name shifts by an hour around DST

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

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
66/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ệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Start with DatetimeToStringConverter.Convert and StringToDatetimeConverter.Convert in converter.go, then run the reproduction using the Europe/Paris fall-back time. Check that formatting includes the offset with the zone name and parsing accepts both forms while rejecting an offset the zone does not have at that time. Done means the round trip preserves the original instant.

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

Mô tả

bug

Reproduction snippets assume:

fac := tupleconv.MakeStringToTTConvFactory()

Where: DatetimeToStringConverter.Convert (converter.go:356), StringToDatetimeConverter.Convert (converter.go:200).

For a datetime with a time zone name, the string form is <local time> <zone name> without an offset. During a DST fall-back hour the same local time happens twice, and the parser always picks one of them.

Reproduction:

paris, _ := time.LoadLocation("Europe/Paris")
cest := time.Date(2023, 10, 29, 0, 30, 0, 0, time.UTC).In(paris)
dt, _ := datetime.NewDatetime(cest)
s, _ := tupleconv.MakeDatetimeToStringConverter().Convert(dt)
back, _ := tupleconv.MakeStringToDatetimeConverter().Convert(s)
bdt := back.(datetime.Datetime)
fmt.Printf("%s -> %q -> %s\n", cest, s, bdt.ToTime())
2023-10-29 02:30:00 +0200 CEST -> "2023-10-29T02:30:00 Europe/Paris" -> 2023-10-29 02:30:00 +0100 CET

Expected: the round trip keeps the instant.

Suggested fix: write the offset together with the zone name, e.g. 2023-10-29T02:30:00+0200 Europe/Paris. When parsing, accept both forms; if the offset is present, choose the instant with that offset and reject an offset the zone doesn't have at that time.

Ngôn ngữ chính
Go
Star
1
Fork
0
Merge trung bình
1 giờ 43 phút
Pull request đã merge (30 ngày)
2

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 tarantool/go-tupleconv

Tất cả issue của tarantool/go-tupleconv

Issue tương tự

Thêm issue về Go

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.