datetime

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package datetime provides custom date and time types with JSON marshaling support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct{ time.Time }

Date represents a date without time using RFC3339 date format (YYYY-MM-DD).

func NewDate added in v0.16.0

func NewDate(year int, month time.Month, day int) Date

NewDate constructs a Date from a calendar date in UTC.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON formats the date as a JSON string in YYYY-MM-DD format.

func (Date) String

func (d Date) String() string

String returns the date formatted as YYYY-MM-DD.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON parses a JSON string in YYYY-MM-DD format.

type Time

type Time struct{ time.Time }

Time represents a time of day using RFC3339 time format (HH:MM:SS).

func NewTime added in v0.16.0

func NewTime(hour, min, sec int) Time

NewTime constructs a Time from a clock time in UTC.

func (Time) MarshalJSON

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

MarshalJSON formats the time as a JSON string in HH:MM:SS format.

func (Time) String

func (t Time) String() string

String returns the time formatted as HH:MM:SS.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON parses a JSON string in HH:MM:SS format.

Jump to

Keyboard shortcuts

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