zone

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package zone renders every timestamp inside a value in one time zone.

It exists because encoding/json writes a time.Time as RFC 3339 INCLUDING the offset it happens to carry, and nothing in Go carries that offset on purpose. A moment computed as now.Add(interval) is in the machine's zone; the same moment parsed off the wire, where Claude's usage endpoint ends every timestamp in Z, is in UTC. Put both in one document and the document has two zones — same instants, and a reader comparing the rows against one wall clock reads half of them as hours out. That is not a hypothetical: a live ccdad store carried five poll times at +09:00 beside one at Z, and the Z row, read as though it were local, looked nine hours overdue while in fact being four minutes in the future.

The rule this package makes executable is that the ZONE BELONGS TO THE DOCUMENT AND NOT TO THE FIELD. It is applied on the way out, at the one place each document is serialised, rather than at every writer that computes a moment: a writer's job is to choose an instant, and an instant has no zone — only its rendering does.

This is the machine-side counterpart of view.Timestamp, which is the one absolute-time rendering for a person. Neither reads the environment: the location arrives as a parameter, so the caller nearest the reader chooses it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func In

func In[T any](v T, loc *time.Location) T

In returns v with every time.Time reachable inside it rendered in loc, and everything else unchanged. The instants are untouched — only the zone they will be written in changes.

v is not modified. Maps, slices and structs on the way to a timestamp are rebuilt rather than written through, because the caller's value is usually still live: daemon.Status is passed by value but its Accounts slice is shared with the engine's own, and normalising in place would reach back into the scheduler's state through a field the writer only meant to read.

A nil location means the machine's zone. That differs from view.Timestamp, which falls back to UTC, and the difference is deliberate: view is handed moments by arithmetic that must not touch the environment, while everything that reaches this function is already being written to or read from a file on the machine the reader is sitting at.

The input must be a tree. Every document ccdad serialises is built fresh out of maps, slices and plain structs, and encoding/json would refuse a cycle a step later anyway.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL