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

Abierto
#16 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Go
Estrellas
1
Forks
0
Merge medio
1 h 43 min
PR fusionados (30 d)
2

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de tarantool/go-tupleconv

Todos los issues de tarantool/go-tupleconv

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.