ЛР 6 — БПИ2302 — Нурлыгаянова — на 3

This commit is contained in:
Nurlygayanova Ekaterina
2026-11-13 11:32:45 +03:00
parent 470d9d6f1e
commit 69a190be0e
164 changed files with 25947 additions and 29 deletions
+20
View File
@@ -0,0 +1,20 @@
package dto
import "time"
const timestampLayout = "2006-01-02T15:04:05.000000Z"
// Timestamp сериализуется в UTC всегда с 6 цифрами дробной части. Стандартный формат
// time.Time отбрасывает нули в конце (…17.95188Z): это корректный RFC 3339, но такое значение
// не разбирает datetime.fromisoformat в Python 3.9–3.10, на которых идут публичные тесты.
type Timestamp struct {
time.Time
}
func NewTimestamp(t time.Time) Timestamp {
return Timestamp{Time: t}
}
func (t Timestamp) MarshalJSON() ([]byte, error) {
return []byte(`"` + t.UTC().Format(timestampLayout) + `"`), nil
}