timeutil

package
v0.0.0-...-3277746 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeFormat = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime 将 time.Time 转换为指定格式的字符串

func ParseTime

func ParseTime(timeStr string) (time.Time, error)

ParseTime 将字符串解析为 time.Time

Types

type JSONTime

type JSONTime time.Time

JSONTime 自定义时间类型,用于JSON序列化

func Now

func Now() JSONTime

Now 返回当前时间的 JSONTime 格式

func (JSONTime) MarshalJSON

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

MarshalJSON 实现 json.Marshaler 接口

func (*JSONTime) Scan

func (t *JSONTime) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于数据库读取

func (JSONTime) String

func (t JSONTime) String() string

String 实现 Stringer 接口

func (*JSONTime) UnmarshalJSON

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

UnmarshalJSON 实现 json.Unmarshaler 接口

func (JSONTime) Value

func (t JSONTime) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于数据库存储

Jump to

Keyboard shortcuts

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