simpletime

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

* @Author: wei-g @Date: 2020/11/25 3:01 下午 @Description: 简化时间序列化操作等有关处理

本文件部分代码实现借鉴 https://www.liwenzhou.com/posts/Go/json_tricks_in_go/#autoid-0-0-12

Index

Constants

View Source
const (
	SecondTimeLayout = "2006-01-02 15:04:05 MST" // 精确到秒,带时区信息
	//TimeLayoutNano       = "2006-01-02 15:04:05.000000000 MST" // 精确到毫秒,带时区信息
	ValidatorSecondTimeTag = "formatSecondTime" // validator 注册 字段基本的tag名
)

Variables

This section is empty.

Functions

func CheckSecondTimeFunc added in v0.3.4

func CheckSecondTimeFunc(fl validator.FieldLevel) bool

Types

type SecondTime

type SecondTime time.Time

SecondTime 精确到秒的时间序列化

func Parse added in v0.3.4

func Parse(value string) (secondTime SecondTime, err error)

Parse parses a formatted string and returns the time value it represents.

func (*SecondTime) IsSet

func (s *SecondTime) IsSet() bool

IsSet 判断Time是否为正确设置

func (*SecondTime) MarshalJSON

func (s *SecondTime) MarshalJSON() (data []byte, err error)

MarshalJSON json 序列化接口

func (*SecondTime) UnmarshalJSON

func (s *SecondTime) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON json 反序列化接口

func (SecondTime) Value added in v0.3.2

func (s SecondTime) Value() (driver.Value, error)

Value 满足 database/sql 库要求

Jump to

Keyboard shortcuts

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