Files
zeekay ef352c1051 debrand: rename the wire client name, prose and linter config
proto.Name is sent in ClientHello and lands in the server's system.query_log,
so it is wire visible; it now reads datastore/native and is covered by a test.
Verified against the live server: the handshake succeeds and the new name
appears in query_log.

goimports' local-prefixes still named the upstream module, so it was not
grouping this module's own imports.

Doc comments, the deprecated-error markers in proto/error_codes.go and the
package prose are swept. Dead references are removed rather than repointed:
go-faster.org/docs/clickhouse and the mangled Datastore/clickhouse-cpp link
both 404, and the list of other vendors' clients does not belong here.

Four things deliberately keep the vendor name, and CI records why:
LICENSE and AUTHORS are the copyright notices Apache-2.0 requires; db.system in
query.go is an OpenTelemetry enum whose registered value for this DBMS is fixed
by the specification, so emitting anything else would be non-conformant; and
README names clickhouse-local, which is genuinely the binary our own server
image ships.

Numeric error codes and protocol revision constants are untouched.
2026-07-26 11:50:36 -07:00

47 lines
1.1 KiB
Go

package proto
import "time"
// Date represents Date value.
//
// https://docs.hanzo.ai/datastore
type Date uint16
// DateLayout is default time format for Date.
const DateLayout = "2006-01-02"
// secInDay represents seconds in day.
//
// NB: works only on UTC, use time.Date, time.Time.AddDate.
const secInDay = 24 * 60 * 60
// Unix returns unix timestamp of Date.
func (d Date) Unix() int64 {
return secInDay * int64(d)
}
// Time returns UTC starting time.Time of Date.
//
// You can use time.Unix(d.Unix(), 0) to get Time in time.Local location.
func (d Date) Time() time.Time {
return time.Unix(d.Unix(), 0).UTC()
}
func (d Date) String() string {
return d.Time().UTC().Format(DateLayout)
}
// ToDate returns Date of time.Time.
func ToDate(t time.Time) Date {
if t.IsZero() {
return 0
}
_, offset := t.Zone()
return Date((t.Unix() + int64(offset)) / secInDay)
}
// NewDate returns the Date corresponding to year, month and day in UTC.
func NewDate(year int, month time.Month, day int) Date {
return ToDate(time.Date(year, month, day, 0, 0, 0, 0, time.UTC))
}