timex

package
v0.0.0-...-5f1e29e Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ODateFormat = "2006-01-02"
View Source
const OTimeFormat = "15:04:05"

Variables

View Source
var CHINESENUMBER = []string{"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
View Source
var CHINESENUMBERSPECIAL = []string{"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"}
View Source
var DATELAYOUT = "2006-01-02"
View Source
var (
	LOC_ZONE = time.FixedZone("CST", 8*3600) // 东八区
)
View Source
var LUNAR_INFO = []int{}/* 150 elements not displayed */
View Source
var MAX_YEAR = 2049
View Source
var MIN_YEAR = 1900
View Source
var MONTHNUMBER = map[string]int{"January": 1, "February": 2, "March": 3, "April": 4, "May": 5, "June": 6, "July": 7, "August": 8, "September": 9, "October": 10, "November": 11, "December": 12}
View Source
var NTPs = []string{
	"cn.pool.ntp.org",
	"cn.ntp.org.cn",
	"edu.ntp.org.cn",
	"ntp.aliyun.com",
	"ntp1.aliyun.com",
	"ntp2.aliyun.com",
	"ntp3.aliyun.com",
	"ntp4.aliyun.com",
	"ntp5.aliyun.com",
	"ntp6.aliyun.com",
	"ntp7.aliyun.com",
	"hk.ntp.org.cn",
	"sgp.ntp.org.cn",
	"us.ntp.org.cn",
	"time.sunqida.cn",
}
View Source
var STARTDATESTR = "1900-01-30"

Functions

func Date

func Date(ti int64, format string) string

Format unix time int64 to string

func DateParse

func DateParse(dateString, format string) (time.Time, error)

Parse Date use PHP time format.

func DateT

func DateT(t time.Time, format string) string

Format time.Time struct to string MM - month - 01 M - month - 1, single bit DD - day - 02 D - day 2 YYYY - year - 2006 YY - year - 06 HH - 24 hours - 03 H - 24 hours - 3 hh - 12 hours - 03 h - 12 hours - 3 mm - minute - 04 m - minute - 4 ss - second - 05 s - second = 5

func DateToString

func DateToString(ts string, format string) string

Format unix time string to string

func GetBetweenDates

func GetBetweenDates(date_start, date_end time.Time) (d []time.Time)

func GetCountDown

func GetCountDown(t time.Time) string

倒计时

func GetDate

func GetDate(src time.Time) time.Time

获取零日期整数 2023-01-02T00:00:00+08:00

func GetDateTime

func GetDateTime(date time.Time, src time.Time) (dst time.Time, _err error)

获取指定日期合成后的时间 2023-01-02T15:04:05+08:00

func GetDateTimeHour

func GetDateTimeHour(src time.Time) time.Time

获取日期时整数 2023-01-02T15:00:00+08:00

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetFirstDateOfWeek

func GetFirstDateOfWeek(d time.Time, start_sunday bool) time.Time

func GetFirstDateOfYear

func GetFirstDateOfYear(d time.Time) time.Time

获取传入的时间所在年第一天

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetZeroTimeOfDay

func GetZeroTimeOfDay(d time.Time) time.Time

获取某一天的0点时间

func IsToday

func IsToday(t time.Time) bool

判断输入时间是否为当天时间

func LunarToSolar

func LunarToSolar(date string, leapMonthFlag bool) (d string, err error)

func SolarToChineseLuanr

func SolarToChineseLuanr(date string) string

func SolarToLuanr

func SolarToLuanr(date string) (string, bool)

func SolarToSimpleLuanr

func SolarToSimpleLuanr(date string) string

func TimeNtpCompare

func TimeNtpCompare(date string) (err error)

data = "2021-10-01"

func TimeNullToTime

func TimeNullToTime(null_time TimeNull) time.Time

func TimeStringToTime

func TimeStringToTime(str_time string, loc_zone *time.Location) time.Time

func UpdateDate

func UpdateDate(src *time.Time) (_err error)

获取零时间 2023-01-01T00:00:00+08:00

func UpdateDateTimeHour

func UpdateDateTimeHour(src *time.Time) (_err error)

修改为日期整时 2023-01-02T15:00:00+08:00

func UpdateHour

func UpdateHour(src *time.Time) (_err error)

获取零日期整时 2000-01-01T15:00:00+08:00

func UpdateTime

func UpdateTime(src *time.Time) (_err error)

获取零日期 舍去秒 2000-01-01T15:04:00+08:00

Types

type ODate

type ODate struct {
	time.Time
}

func (ODate) MarshalJSON

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

func (*ODate) Scan

func (t *ODate) Scan(v interface{}) error

func (*ODate) UnmarshalJSON

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

func (ODate) Value

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

type OTime

type OTime struct {
	time.Time
}

func (*OTime) IsNull

func (t *OTime) IsNull() bool

func (OTime) MarshalJSON

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

func (*OTime) Scan

func (t *OTime) Scan(v interface{}) error

func (*OTime) UnmarshalJSON

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

func (OTime) Value

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

type TimeNull

type TimeNull struct {
	sql.NullTime
}

func TimeNullNow

func TimeNullNow() TimeNull

func TimeStringToTimeNull

func TimeStringToTimeNull(str_time string, loc_zone *time.Location) TimeNull

func TimeToTimeNull

func TimeToTimeNull(t time.Time) TimeNull

func UpdateTimeNull

func UpdateTimeNull(t time.Time) TimeNull

func (TimeNull) Add

func (v TimeNull) Add(time_long time.Duration) TimeNull

func (TimeNull) MarshalJSON

func (v TimeNull) MarshalJSON() ([]byte, error)

func (*TimeNull) Now

func (v *TimeNull) Now() TimeNull

func (*TimeNull) UnmarshalJSON

func (v *TimeNull) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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