Documentation ¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-10-15 15:55:10 * @FilePath: \go-toolbox\pkg\moment\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-10 18:55:05 * @FilePath: \go-toolbox\pkg\moment\constants.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-10-17 15:56:55 * @FilePath: \go-toolbox\pkg\moment\date.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-01 02:01:27 * @FilePath: \go-toolbox\pkg\moment\time.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- Constants
- func CharToCode(layout string) string
- func ConvertStringToTimestamp(dateString, layout string, timeZone string) (int64, error)
- func CurrentGmtTime() string
- func CurrentMicrosecond() int64
- func CurrentMillisecond() int64
- func CurrentNanosecond() int64
- func FormatWithLocation(timezone string, ts int64, defaultDateFormat string) string
- func GetCurrentTimeInfo() (string, int, time.Time)
- func GetServerTimezone() string
- func GetTimeOffset(timezone string, ts int64) (offset int)
- func LocalTime() string
- func ParseDay(t ...time.Time) int
- func ParseHour(t ...time.Time) int
- func ParseMinute(t ...time.Time) int
- func ParseMonth(t ...time.Time) int
- func ParseSecond(t ...time.Time) int
- func ParseString(f ...string) string
- func ParseTimestamp(args ...string) int64
- func ParseWithLocation(timezone string, timeStr string, defaultDateFormat string) int64
- func ParseYear(t ...time.Time) int
- func ParseYearDay(t ...time.Time) int
- func SafeParseTimeToUnixNano(timeStr string) int64
- func StrtoTime(s string, args ...string) (time.Time, error)
- type TimeDifference
Constants ¶
const ( // 默认时区 DefaultTimezone = "Asia/Shanghai" // Nanosecond 纳秒,作为最基础的单位 Nanosecond time.Duration = 1 // Microsecond 微妙,表示1微妙持续的纳秒时长 Microsecond = 1000 * Nanosecond // Millisecond 毫秒,表示1毫秒持续的纳秒时长 Millisecond = 1000 * Microsecond // Second 秒,表示1秒持续的纳秒时长 Second = 1000 * Millisecond // Minute 分钟,表示1分钟持续的纳秒时长 Minute = 60 * Second // Hour 小时,表示1小时持续的纳秒时长 Hour = 60 * Minute // Day 天,表示1天持续的纳秒时长 // 这里不考虑夏时制问题,泛指国际基础单位制(民用日)所理解的时间 Day = 24 * Hour // Week 周, 表示1周持续的纳秒时长 // 这里不考虑夏时制问题,泛指国际基础单位制(民用日)所理解的时间 Week = 7 * Day // Year 年,表示1年持续的纳秒时长 Year = 365 * Day )
通用的时间单位持续时长,这里泛指国际基础单位制(民用日)所理解的时间,不考虑夏时制,不用作科学与天文学 例如 一天 24小时,一周 168小时,7天
Variables ¶
This section is empty.
Functions ¶
func CharToCode ¶
func ConvertStringToTimestamp ¶
ConvertStringToTimestamp String时间类型转换为时间戳
func FormatWithLocation ¶
FormatWithLocation 国际化时间戳转换字符串
func GetCurrentTimeInfo ¶
GetCurrentTimeInfo 获取当前日期、小时和时间的通用函数
func GetTimeOffset ¶
GetTimeOffset 国际化时间戳偏移
func ParseMonth ¶
func ParseWithLocation ¶
ParseWithLocation 国际化时间字符串转换时间戳
func ParseYearDay ¶
func SafeParseTimeToUnixNano ¶
SafeParseTimeToUnixNano
Types ¶
type TimeDifference ¶
TimeDifference 结构体用于存储年、天、小时、分钟和秒
func CalculateTimeDifference ¶
func CalculateTimeDifference(duration time.Duration) TimeDifference
CalculateTimeDifference 计算给定的 time.Duration,并返回 TimeDifference