timeutils

package
v0.0.0-...-1147cba Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatYMD = "yyyy-MM-dd"
	// YYYY_MM_DD_HH_MM_SS_SSS is the format "2006-01-02 15:04:05.000".
	YYYY_MM_DD_HH_MM_SS_SSS = "2006-01-02 15:04:05.000"
	// YYYY_MM_DD_HH_MM_SS is the format "2006-01-02 15:04:05".
	YYYY_MM_DD_HH_MM_SS = "2006-01-02 15:04:05"
	// YYYY_MM_DD is the format "2006-01-02".
	YYYY_MM_DD = "2006-01-02"
	// DD_MM_YYYY is the format "02-01-2006".
	DD_MM_YYYY = "02-01-2006"
	// DD_MM_YYYY_HH_MM_SS is the format "02-01-2006 15:04:05".
	DD_MM_YYYY_HH_MM_SS = "02-01-2006 15:04:05"
	// DD_MM_YYYY_HH_MM_SS_SSS is the format "02-01-2006 15:04:05.000".
	DD_MM_YYYY_HH_MM_SS_SSS = "02-01-2006 15:04:05.000"

	DMFormat = "d/m"
)

Variables

This section is empty.

Functions

func ConvertTimeToGMT07

func ConvertTimeToGMT07(t time.Time) time.Time

func ConvertToUnixTime

func ConvertToUnixTime(t time.Time) int64

func ConvertUnixTimeRFC3339String

func ConvertUnixTimeRFC3339String(timeStamp int64) string

* Convert timestamp to string with custom RFC3339 format without GMT ex: 2006-01-02T15:04:05Z07:00

func GMT07Location

func GMT07Location() *time.Location

func GetBeginTimeOfDay

func GetBeginTimeOfDay(timestamp int64) int64

func GetDayOfWeekNameNormalLetter

func GetDayOfWeekNameNormalLetter(dayOfWeek time.Weekday) string

GetDayOfWeekName get name of day of week, sunday is 0, 1 to 6 is from monday to saturday

func GetDayOfWeekNameShort

func GetDayOfWeekNameShort(dayOfWeek time.Weekday) string

func GetDayOfWeekNameUpperFirstLetter

func GetDayOfWeekNameUpperFirstLetter(dayOfWeek time.Weekday) string

GetDayOfWeekName get name of day of week, sunday is 0, 1 to 6 is from monday to saturday

func GetDaysBetweenDates

func GetDaysBetweenDates(first, second time.Time) int64

func Init

func Init()

func IsEqualDate

func IsEqualDate(t1, t2 time.Time) bool

func IsOnTheSameDate

func IsOnTheSameDate(t1, t2 time.Time) bool

func NowInGMT07String

func NowInGMT07String(format string) string

func NowInGMT07StringRFC3339

func NowInGMT07StringRFC3339() string

func ParseOpenTimeText

func ParseOpenTimeText(opensAt int64, closesAt int64) string

func ParseStringDateToFormatDate

func ParseStringDateToFormatDate(timeString string, format string) string

func ParseStringToTime

func ParseStringToTime(timeString string) time.Time

ParseStringToTime convert string to time object

func ParseStringToUnixTimestampLocation

func ParseStringToUnixTimestampLocation(timeStr string) int64

* Convert timestamp to string with custom RFC3339 format without GMT07 ex: 2006-01-02T15:04:05Z07:00

func ParseTimestampToFormatDate

func ParseTimestampToFormatDate(timeStamp int64, format string) string

func TimeBeginDayByTime

func TimeBeginDayByTime(t time.Time) time.Time

TimeBeginDayByTime convert time to time begin of day

func TimeEndDayByTime

func TimeEndDayByTime(t time.Time) time.Time

TimeEndDayByTime convert time to time end of day

func TimeInGMT07String

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

func TimeInGMT07StringRFC3339

func TimeInGMT07StringRFC3339(t time.Time) string

func TimestampToGMT07Time

func TimestampToGMT07Time(timestamp int64) time.Time

func TimestampToTimeUTC

func TimestampToTimeUTC(timestamp int64) time.Time

Types

type Date

type Date time.Time

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) Scan

func (d *Date) Scan(value interface{}) error

func (Date) ToString

func (d Date) ToString() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

func (Date) Value

func (d Date) Value() (driver.Value, error)

type DateTime

type DateTime time.Time

func (DateTime) MarshalJSON

func (d DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) Scan

func (d *DateTime) Scan(value interface{}) error

func (DateTime) ToString

func (d DateTime) ToString() string

func (*DateTime) UnmarshalJSON

func (d *DateTime) UnmarshalJSON(data []byte) error

func (DateTime) Value

func (d DateTime) Value() (driver.Value, error)

type NowFn

type NowFn func() time.Time

type NowTimestampFn

type NowTimestampFn func() int64

Jump to

Keyboard shortcuts

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