Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse builds a Time from a layout and a value (see time.Parse).
On success the Result carries the Time as its payload; when the value does not match the layout the Result carries an Error instead — the operation never panics and never returns nil.
r := Time.Parse(time.RFC3339, "2026-06-20T12:00:00Z")
if r.HasError() {
// r.Error().Message()
}
func ParseAny ¶
ParseAny builds a Time from a date/time string WITHOUT an explicit layout, trying the real-world format zoo — RFC 822/1123/2822/3339/5322, asctime, HTTP, 2-digit years, ISO 8601 and named-zone abbreviations — via the shared go-datetime/dates parser. This is the lenient, MRI-style Time.parse behaviour (Ruby's Time.parse accepts almost any recognisable date), so consumers such as the rbgo interpreter delegate here instead of reimplementing a layout table.
On success the Result carries the Time; an unrecognisable value carries an Error; the operation never panics and never returns nil.
r := Time.ParseAny("Tue, 07 Jul 26 11:13:37 UTC") // 2-digit year + named zone
Types ¶
type Interface ¶
type Interface interface {
ToUnix() int64
Format(layout string) string
ToGoString() string
In(name string) Result.Interface
Zone() string
UTC() Interface
Before(Interface) bool
After(Interface) bool
Equal(Interface) bool
Add(Duration.Interface) Result.Interface
Sub(Interface) Duration.Interface
IsNull() bool
}
Time is a composite over an instant in time, wrapping Go's stdlib time.Time (Ruby's Time as the reference).
It follows Composition-Oriented Programming: it is interface-first, its fallible constructors (Parse, Add) return a Result.Interface so that failures are values rather than panics, and it ships a Null-Object variant so callers never have to test for a bare nil.
Time is deterministic by construction: there is no Now(). Instances are built only from explicit values (FromUnix, Parse), which keeps behaviour reproducible across architectures and test runs.