types

package
v0.12.10 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 1 Imported by: 0

README

Types Package

The types package provides custom type definitions and utilities for common data types.

Features

  • DateTime Type: Custom time type with JSON serialization
  • Standard Format: Consistent datetime formatting across the application
  • JSON Integration: Automatic marshaling/unmarshaling

Main Components

DateTime

Custom time type for consistent datetime handling:

  • Based on time.Time
  • Format: 2006-01-02 15:04:05 (local time)
  • JSON marshaling/unmarshaling support
Methods
  • UnmarshalJSON(data): Parse from JSON string
  • MarshalJSON(): Convert to JSON string
  • String(): Format as string
  • Time(): Convert to standard time.Time

Usage

// Use DateTime in structs
type MyModel struct {
    CreatedAt types.DateTime
}

// Automatically handles JSON serialization
// Input: "2024-01-15 10:30:00"
// Output: "2024-01-15 10:30:00"

Format

The datetime format is: 2006-01-02 15:04:05

This follows Go's reference time format and represents:

  • Year-Month-Day Hour:Minute:Second
  • Local timezone

Dependencies

  • Standard library time package

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DatetimeFormat = "2006-01-02 15:04:05"

const (

Functions

This section is empty.

Types

type DateTime

type DateTime time.Time

func (DateTime) MarshalJSON

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

func (DateTime) String

func (t DateTime) String() string

func (DateTime) Time

func (t DateTime) Time() time.Time

func (*DateTime) UnmarshalJSON

func (t *DateTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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