Documentation ¶
Index ¶
- Constants
- func DateTime(format string, datetime any, extraAttrs ...string) template.HTML
- func GetExecutableModTime() time.Time
- func MinutesToFriendly(minutes int, lang translation.Locale) string
- func MockSet(now time.Time)
- func MockUnset()
- func TimeSince(then time.Time, lang translation.Locale) template.HTML
- func TimeSincePro(then time.Time, lang translation.Locale) string
- func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML
- type TimeStamp
- func (ts TimeStamp) Add(seconds int64) TimeStamp
- func (ts TimeStamp) AddDuration(interval time.Duration) TimeStamp
- func (ts TimeStamp) AsLocalTime() time.Time
- func (ts TimeStamp) AsTime() (tm time.Time)
- func (ts TimeStamp) AsTimeInLocation(loc *time.Location) time.Time
- func (ts TimeStamp) AsTimePtr() *time.Time
- func (ts TimeStamp) AsTimePtrInLocation(loc *time.Location) *time.Time
- func (ts TimeStamp) Format(f string) string
- func (ts TimeStamp) FormatDate() string
- func (ts TimeStamp) FormatInLocation(f string, loc *time.Location) string
- func (ts TimeStamp) IsZero() bool
- func (ts TimeStamp) Year() int
- type TimeStampNano
Constants ¶
const ( Minute = 60 Hour = 60 * Minute Day = 24 * Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month )
Seconds-based time units
Variables ¶
This section is empty.
Functions ¶
func GetExecutableModTime ¶ added in v1.16.0
GetExecutableModTime get executable file modified time of current process.
func MinutesToFriendly ¶
func MinutesToFriendly(minutes int, lang translation.Locale) string
MinutesToFriendly returns a user friendly string with number of minutes converted to hours and minutes.
func TimeSincePro ¶
func TimeSincePro(then time.Time, lang translation.Locale) string
TimeSincePro calculates the time interval and generate full user-friendly string.
func TimeSinceUnix ¶
func TimeSinceUnix(then TimeStamp, lang translation.Locale) template.HTML
TimeSinceUnix renders relative time HTML given a TimeStamp
Types ¶
type TimeStamp ¶
type TimeStamp int64
TimeStamp defines a timestamp
func (TimeStamp) AddDuration ¶
AddDuration adds time.Duration and return sum
func (TimeStamp) AsLocalTime ¶ added in v1.17.2
AsLocalTime convert timestamp as time.Time in local location
func (TimeStamp) AsTimeInLocation ¶
AsTimeInLocation convert timestamp as time.Time in Local locale
func (TimeStamp) AsTimePtrInLocation ¶
AsTimePtrInLocation convert timestamp as *time.Time in customize location
func (TimeStamp) FormatDate ¶ added in v1.12.0
FormatDate formats a date in YYYY-MM-DD
func (TimeStamp) FormatInLocation ¶
FormatInLocation formats timestamp as given format with spiecific location
type TimeStampNano ¶ added in v1.20.0
type TimeStampNano int64
TimeStampNano is for nano time in database, do not use it unless there is a real requirement.
func TimeStampNanoNow ¶ added in v1.20.0
func TimeStampNanoNow() TimeStampNano
TimeStampNanoNow returns now nano int64
func (TimeStampNano) AsTime ¶ added in v1.20.0
func (tsn TimeStampNano) AsTime() (tm time.Time)
AsTime convert timestamp as time.Time in Local locale
func (TimeStampNano) AsTimeInLocation ¶ added in v1.20.0
func (tsn TimeStampNano) AsTimeInLocation(loc *time.Location) time.Time
AsTimeInLocation convert timestamp as time.Time in Local locale