time

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: GPL-3.0 Imports: 4 Imported by: 12

Documentation

Index

Constants

View Source
const (
	DefaultTimeZone       = ""
	DefaultDateFormat     = "yyyy-MM-dd"
	DefaultTimeFormat     = "HH:mm:ss"
	DefaultDateTimeFormat = DefaultDateFormat + " " + DefaultTimeFormat
)

Variables

View Source
var DaysOfMonth = map[time.Month]int{
	time.January:   31,
	time.February:  28,
	time.March:     31,
	time.April:     30,
	time.May:       31,
	time.June:      30,
	time.July:      31,
	time.August:    31,
	time.September: 30,
	time.October:   31,
	time.November:  30,
	time.December:  31,
}

DaysOfMonth 每月的天数

Functions

func AddDateSeparator

func AddDateSeparator(date, separator string, incDay bool) string

AddDateSeparator 将YYYYMMDD格式的日期转换为YYYY-MM-DD格式或者YYYY-MM格式

func GetDateSeparator

func GetDateSeparator(date string) string

GetDateSeparator 获取日期分隔符

func GetShortDate

func GetShortDate(date string) string

GetShortDate 获取短日期字符串

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear 是否为润年

func NowTime

func NowTime() time.Time

NowTime 获取当前时间(默认时区)

func NowTimeEx

func NowTimeEx(timeZone string) time.Time

NowTimeEx 获取当前时间(指定时区)

func NowTimeText

func NowTimeText(format string) string

NowTimeText 获取当前时间(默认时区)

func NowTimeTextEx

func NowTimeTextEx(timeZone, format string) string

NowTimeTextEx 获取当前时间(指定时区)

func RemoveDateSeparator

func RemoveDateSeparator(date string) string

RemoveDateSeparator 去掉日期中的连接符-/和空格

func RemoveTimeFromDateTime

func RemoveTimeFromDateTime(date string) string

RemoveTimeFromDateTime 将日期时间字符串中的时间信息去掉

func ToDayEnd

func ToDayEnd(t time.Time) time.Time

ToDayEnd 将日期时间转换成 yyyy-MM-dd 23:59:59:999

func ToDayStart

func ToDayStart(t time.Time) time.Time

ToDayStart 将日期时间转换成 yyyy-MM-dd 00:00:00:000

func ToInt64

func ToInt64(t time.Time, format string) int64

ToInt64 将日期时间格式化字符串后再转换成64位整数

Types

type DateDifference

type DateDifference struct {
	Years  int
	Months int
	Days   int
}

DateDifference 日期差

func CalculateDateDifference

func CalculateDateDifference(start, end time.Time) *DateDifference

CalculateDateDifference 计算日期差

Jump to

Keyboard shortcuts

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