freelotime

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package freelotime defines a time.Time wrapper that handles Freelo's two on-the-wire timestamp formats:

  • RFC3339 with timezone, e.g. "2026-04-24T11:12:38+02:00" or "...Z".
  • Local-time without timezone, e.g. "2026-04-24T11:12:38". Server-side this represents wall-clock time in Europe/Prague.

The generated client (freeloapi) uses freelotime.Time on every `format: date-time` field so typed *WithResponse methods decode out of the box. Consumers can also construct freelotime.Time values directly.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTime = errors.New("freelo: invalid timestamp format")

ErrInvalidTime is returned when UnmarshalJSON receives a string that matches neither RFC3339 nor the local-time layout. Wrapped in the returned error; check via errors.Is.

Functions

This section is empty.

Types

type Time

type Time struct {
	time.Time
}

Time wraps time.Time with JSON (un)marshalling that tolerates Freelo's two timestamp shapes:

  • RFC3339 with timezone, e.g. "2026-04-24T11:12:38+02:00" or "...Z". Honored as-is; the result is normalized to UTC.

  • Local-time without timezone, e.g. "2026-04-24T11:12:38". This is what most Freelo endpoints emit today. Interpreted as Europe/Prague wall-clock and converted to UTC.

Marshalling always emits RFC3339 in UTC (e.g. "2026-04-24T09:12:38Z"), which the server accepts on the way back in.

Use freelo.Time anywhere the generated client expects a date-time field; the spec preprocessor in scripts/specgen wires this in by injecting `x-go-type: freelo.Time` on every `format: date-time` schema before oapi-codegen runs.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON emits the embedded time as RFC3339 in UTC. Zero values marshal to JSON null so the field can be safely omitempty-guarded by the generated client.

func (Time) String

func (t Time) String() string

String returns the RFC3339-UTC form, matching MarshalJSON without quotes.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a JSON string per the rules documented on Time.

Jump to

Keyboard shortcuts

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