datetime

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SECONDS_PER_MINUTE = 60
	MINUTES_PER_HOUR   = 60
	HOURS_PER_DAY      = 24
	DAY_PER_WEEK       = 7
	SECONDS_PER_HOUR   = SECONDS_PER_MINUTE * MINUTES_PER_HOUR
	SECONDS_PER_DAY    = SECONDS_PER_HOUR * HOURS_PER_DAY
	MINUTES_PER_DAY    = MINUTES_PER_HOUR * HOURS_PER_DAY
	SECONDS_PER_WEEK   = SECONDS_PER_DAY * DAY_PER_WEEK

	MS_PER_MINUTE = SECONDS_PER_MINUTE * 1000
	MS_PER_HOUR   = SECONDS_PER_HOUR * 1000
	MS_PER_DAY    = SECONDS_PER_DAY * 1000
	MS_PER_SECOND = 1000
)

const

Variables

View Source
var (
	//地区时间偏移配置定义
	ZoneTimeOffset = map[string]int32{}/* 159 elements not displayed */

)

Functions

func AppInTimeRangeByZone

func AppInTimeRangeByZone(start_time, end_time int64, local_tz bool, utc_offset int32, country string, app_time int64) bool

* @title: 判断指定时间是否在活动时间内,支持不同时区 * @description: 根据传入的时间,还有时区差,判断是否在活动时间内 * @param: 开始时间,结束时间,时区偏移 * @return: bool * @author Iori

func BeginTimeOfToday

func BeginTimeOfToday() int32

* * @Description: 获取今日当前的秒数 * @return: int32 * @Author: Iori *

func DiffDay

func DiffDay(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几天,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func DiffHour

func DiffHour(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几小时,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func DiffMin

func DiffMin(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几分,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func DiffMonth

func DiffMonth(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几月,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func DiffTimeRange

func DiffTimeRange(start_time, end_time int64, local_tz bool, utc_offset int32, country string) int64

* * @Description: 对比活动时间差了多少秒 * @param: start_time * @param: end_time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: int64 * @Author: Iori *

func DiffWeek

func DiffWeek(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几周,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func DiffYear

func DiffYear(t1 int64, local_tz bool, utc_offset int32, country string) int32

* * @Description: 判断当前时间差几年,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func GetConfTimeOffset

func GetConfTimeOffset(country string) int32

* * @Description: 根据国家参数读取大区配置时间偏移值 * @param: country * @return: int32 * @Author: Iori *

func GetData

func GetData() string

* * @Description: 获取当前日期格式 YYYY-MM-DD * @return: string * @Author: Iori *

func GetDataHMS

func GetDataHMS() string

* * @Description: 获取当前日期格式 YYYY-MM-DD HH:MM:SS * @return: string * @Author: Iori *

func GetDateByDiff

func GetDateByDiff(diff int32) string

* @title: 获取某个时区的当前日期 * @description: YYYY-MM-DD 支持时区 * @param: diff 时区偏移 分钟 * @return: string 日期 * @author Iori

func GetDateByZone

func GetDateByZone(diff int32) string

* @title: 获取某个时区的当前日期 * @description: YYYY-MM-DD 支持时区 * @param: diff 时区偏移 小时 * @return: string 日期 * @author Iori

func GetDayOfMonth

func GetDayOfMonth(t1 int32) int32

* * @Description: 获取当前月的第几天 * @param: t1 * @return: int32 * @Author: Iori *

func GetDayOfWeek

func GetDayOfWeek(t1 int32) int32

* * @Description: 获取当前周的第几天 * @param: t1 * @return: int32 * @Author: Iori *

func GetHourMinute

func GetHourMinute() (int, int)

* * @Description: 获取小时,分钟 * @return: int * @return: int * @Author: Iori *

func GetHourMinuteForTime

func GetHourMinuteForTime(now int32) (int, int)

* * @Description: 根据传入time 获取小时分钟 * @param: now time * @return: int * @return: int * @Author: Iori *

func GetTimeByDiff

func GetTimeByDiff(diff int64) int64

* @title: 活动对应时区的时间戳 * @description: 手动时区偏移,得到对应时区的时间戳 * @param: 时区偏移 支持分钟 * @return: int64 时间戳

func GetTimeByZone

func GetTimeByZone(diff int64) int64

* @title: 活动对应时区的时间戳 * @description: 手动时区偏移,得到对应时区的时间戳 * @param: 时区偏移 * @return: int64 时间戳

func GetTodayAssignTime

func GetTodayAssignTime(t time.Time, hour, minute int) time.Time

* * @Description: 获取当天XX:XX分的时间 * @param: t * @param: hour * @param: minute * @return: time.Time * @Author: Iori *

func GetUtcTimeSec

func GetUtcTimeSec(time_str string) int64

* @title: 获取时间字符串的时间戳 * @description: 根据时间字符串,得到时间戳,秒单位 * @param: 时间字符串 * @return: int64 时间戳

func GetYearByDiff

func GetYearByDiff(diff int32) string

* @title: 获取某个时区的当前年 * @description: YYYY 支持时区 * @param: diff 时区偏移 分钟 * @return: string 日期 * @author Iori

func GetYearMonthByDiff

func GetYearMonthByDiff(diff int32) string

* @title: 获取某个时区的当前年与月 * @description: YYYY-MM 支持时区 * @param: diff 时区偏移 分钟 * @return: string 日期 * @author Iori

func GetYearWeekByDiff

func GetYearWeekByDiff(diff int32) (int, int)

* @title: 获取某个时区的当前第几周 * @description: YYYY-MM 支持时区 * @param: diff 时区偏移 分钟 * @return: string 日期 * @author Iori

func GetZoneTimeSec

func GetZoneTimeSec(time_str string, diff int64) int64

* @title: 获取字符串时间对应时区的时间戳 * @description: 根据时间字符串,得到对应时区时间戳,秒单位 * @param: 时间字符串,时区偏移 * @return: int64 时间戳

func HowDiffDays

func HowDiffDays(t1, t2 int64) int32

* * @Description: 计算相差的天数 * @param: t1 * @param: t2 * @return: int * @Author: Iori *

func HowDiffHour

func HowDiffHour(t1, t2 int64) int32

* * @Description: 差多少小时 * @param: t1 * @param: t2 * @return: int32 * @Author: Iori *

func HowDiffMin

func HowDiffMin(t1, t2 int64) int32

* * @Description: 差多少分钟 * @param: t1 * @param: t2 * @return: int32 * @Author: Iori *

func HowDiffMonth

func HowDiffMonth(t1, t2 int64) int32

* * @Description: 差多少月 * @param: t1 * @param: t2 * @return: int32 * @Author: Iori *

func HowDiffWeek

func HowDiffWeek(t1, t2 int64) int32

* * @Description: 差多少周 * @param: t1 * @param: t2 * @return: int32 * @Author: Iori *

func HowDiffYear

func HowDiffYear(t1, t2 int64) int32

* * @Description: 差多少年 * @param: t1 * @param: t2 * @return: int32 * @Author: Iori *

func InTimeRange

func InTimeRange(bSecond, eSecond int) bool

* * @Description: 时间区间,一般用来判断是否活动开启时间 -- 只限当地时区 * @param: bSecond * @param: eSecond * @return: bool * @Author: Iori *

func InTimeRangeByStr

func InTimeRangeByStr(start_str, end_str string, diff int64) bool

* @title: 判断是否在活动时间内,支持不同时区 * @description: 根据字符串的活动时间,还有时区差,判断是否在活动时间内 * @param: 开始时间,结束时间,时区偏移 * @return: bool * @author Iori

func InTimeRangeByZone

func InTimeRangeByZone(start_time, end_time int64, local_tz bool, utc_offset int32, country string) bool

* @title: 判断是否在活动时间内,支持不同时区 * @description: 根据传入的时间,还有时区差,判断是否在活动时间内 * @param: 开始时间,结束时间,时区偏移 * @return: bool * @author Iori

func IsSameDay

func IsSameDay(t1, t2 int64) bool

* * @Description: 是否同一天 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameDayByDayBeginHour

func IsSameDayByDayBeginHour(t1, t2 int64, dayBeginTime int) bool

* * @Description: 是否已到开始的小时时间 * @param: t1 * @param: t2 * @param: dayBeginTime * @return: bool * @Author: Iori *

func IsSameHour

func IsSameHour(t1, t2 int64) bool

* * @Description: 是否同一小时 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameHourBySec

func IsSameHourBySec(t1, t2 int64) bool

* * @Description: 是否同一小时,根据秒来计算 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameMinute

func IsSameMinute(t1, t2 int64) bool

* * @Description: 是否同一分钟 * @param: t1 * @param: t2 * @return: bool *

func IsSameMinuteBySec

func IsSameMinuteBySec(t1, t2 int64) bool

* * @Description: 是否同一分钟,根据秒来计算 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameMonth

func IsSameMonth(t1, t2 int64) bool

* * @Description: 是否同一月 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameWeek

func IsSameWeek(t1, t2 int64) bool

* * @Description: 是否同一周 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func IsSameYear

func IsSameYear(t1, t2 int64) bool

* * @Description: 是否同一年 * @param: t1 * @param: t2 * @return: bool * @Author: Iori *

func LocalTimestamp

func LocalTimestamp(tt int64, local_tz bool, utc_offset int32, country string) int64

* * @Description: 获取偏移时间戳 * @param: tt * @param: local_tz * @param: utc_offset 偏移分钟 * @param: country * @return: int64 时间戳 * @Author: Iori *

func Now

func Now() int32

* * @Description: 获取当前时间 now,返回int32秒,支持OffSet * @return: int32 * @Author: Iori *

func NowInt64

func NowInt64() int64

* * @Description: 获取当前时间now,返回int64秒,支持OffSet * @return: int64 * @Author: Iori *

func NowMs

func NowMs() int64

* * @Description: 获取当前时间now,返回int64毫秒,支持OffSet * @return: int64 * @Author: Iori *

func NowNoOffset

func NowNoOffset() int32

* * @Description: 获取当前时间 now,不带OffSet * @return: int32 * @Author: Iori *

func NowT

func NowT() time.Time

* * @Description: 获取当前now time * @return: time.Time * @Author: Iori *

func NowUs

func NowUs() int64

* * @Description: 获取当前时间now,返回int64纳秒,支持OffSet * @return: int64 * @Author: Iori *

func ParseTimestamp

func ParseTimestamp(time_format string, local_tz bool, utc_offset int32, country string) int64

* * @Description: 根据字符串获取时间戳 * @param: time_format * @param: local_tz * @param: utc_offset * @return: int64 * @Author: Iori *

func SameDay

func SameDay(t1 int64, local_tz bool, utc_offset int32, country string) bool

* * @Description: 判断是否同一天,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func SameHour

func SameHour(t1 int64, local_tz bool, utc_offset int32, country string) bool

* * @Description: 判断是否同一小时,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func SameMonth

func SameMonth(t1 int64, local_tz bool, utc_offset int32, country string) bool

* * @Description: 判断是否同一月,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func SameWeek

func SameWeek(t1 int64, local_tz bool, utc_offset int32, country string) bool

* * @Description: 判断是否同一周,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func SameYear

func SameYear(t1 int64, local_tz bool, utc_offset int32, country string) bool

* * @Description: 判断是否同一年,支持时区偏移 * @param: time * @param: local_tz * @param: utc_offset 偏移分钟 * @return: bool * @Author: Iori *

func SetAutoRefresh

func SetAutoRefresh()

* * @Description: AutoRefresh flag * @Author: Iori *

func SetTimeOffset

func SetTimeOffset(offset int32)

* * @Description: set Offset * @param: offset * @Author: Iori *

func Tick

func Tick()

* * @Description: 外部tick * @Author: Iori *

Types

type Gtime

type Gtime struct {
	TimeNow     time.Time
	AutoRefresh bool

	TimeOffSet int32
}

* Gtime * @Description: time struct

Jump to

Keyboard shortcuts

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