datetime

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDay

func AddDay(t time.Time, day int64) time.Time

AddDay add or sub day to the time.

func AddHour

func AddHour(t time.Time, hour int64) time.Time

AddHour add or sub hour to the time.

func AddMinute

func AddMinute(t time.Time, minute int64) time.Time

AddMinute add or sub minute to the time.

func AddYear

func AddYear(t time.Time, year int64) time.Time

AddYear add or sub year to the time.

func BeginOfDay

func BeginOfDay(t time.Time) time.Time

BeginOfDay return beginning hour time of day.

func BeginOfHour

func BeginOfHour(t time.Time) time.Time

BeginOfHour return beginning hour time of day.

func BeginOfMinute

func BeginOfMinute(t time.Time) time.Time

BeginOfMinute return beginning minute time of day.

func BeginOfMonth

func BeginOfMonth(t time.Time) time.Time

BeginOfMonth return beginning of month.

func BeginOfWeek

func BeginOfWeek(t time.Time, beginFrom ...time.Weekday) time.Time

BeginOfWeek return beginning week, default week begin from Sunday.

func BeginOfYear

func BeginOfYear(t time.Time) time.Time

BeginOfYear return the date time at the begin of year.

func BetweenSeconds

func BetweenSeconds(t1 time.Time, t2 time.Time) int64

BetweenSeconds returns the number of seconds between two times.

func DayOfYear

func DayOfYear(t time.Time) int

DayOfYear returns which day of the year the parameter date `t` is.

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay return end time of day.

func EndOfHour

func EndOfHour(t time.Time) time.Time

EndOfHour return end hour time of day.

func EndOfMinute

func EndOfMinute(t time.Time) time.Time

EndOfMinute return end minute time of day.

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

EndOfMonth return end of month.

func EndOfWeek

func EndOfWeek(t time.Time, endWith ...time.Weekday) time.Time

EndOfWeek return end week time, default week end with Saturday.

func EndOfYear

func EndOfYear(t time.Time) time.Time

EndOfYear return the date time at the end of year.

func GetNightTimestamp

func GetNightTimestamp() int64

GetNightTimestamp return timestamp of zero hour (timestamp of 23:59).

func GetNowDate

func GetNowDate() string

GetNowDate return format yyyy-mm-dd of current date.

func GetNowDateTime

func GetNowDateTime() string

GetNowDateTime return format yyyy-mm-dd hh-mm-ss of current datetime.

func GetNowTime

func GetNowTime() string

GetNowTime return format hh-mm-ss of current time.

func GetTodayEndTime

func GetTodayEndTime() string

GetTodayEndTime return the end time of today, format: yyyy-mm-dd 23:59:59.

func GetTodayStartTime

func GetTodayStartTime() string

GetTodayStartTime return the start time of today, format: yyyy-mm-dd 00:00:00.

func GetZeroHourTimestamp

func GetZeroHourTimestamp() int64

GetZeroHourTimestamp return timestamp of zero hour (timestamp of 00:00).

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear check if param year is leap year or not.

func IsWeekend

func IsWeekend(t time.Time) bool

IsWeekend checks if passed time is weekend or not. Deprecated Use '== Weekday' instead

func NewFormat

func NewFormat(t string) (*theTime, error)

NewFormat return unix timestamp of specified time string, t should be "yyyy-mm-dd hh:mm:ss".

func NewISO8601

func NewISO8601(iso8601 string) (*theTime, error)

NewISO8601 return unix timestamp of specified iso8601 time string.

func NewUnix

func NewUnix(unix int64) *theTime

NewUnix return unix timestamp of specified time.

func NewUnixNow

func NewUnixNow() *theTime

NewUnixNow return unix timestamp of current time.

func NowDateOrTime

func NowDateOrTime(format string, timezone ...string) string

NowDateOrTime return current datetime with specific format and timezone.

func NowTime

func NowTime(timezone ...string) time.Time

NowTime return current datetime.

func Strftime

func Strftime(t time.Time, format string, timezone ...string) string

Strftime convert time to string.

func Strptime

func Strptime(str, format string, timezone ...string) (time.Time, error)

Strptime convert string to time.

func Timestamp

func Timestamp(timezone ...string) int64

Timestamp return current second timestamp.

func TimestampMicro

func TimestampMicro(timezone ...string) int64

TimestampMicro return current micro second timestamp.

func TimestampMilli

func TimestampMilli(timezone ...string) int64

TimestampMilli return current mill second timestamp.

func TimestampNano

func TimestampNano(timezone ...string) int64

TimestampNano return current nano second timestamp.

func ToTimezone

func ToTimezone(t time.Time, timezone string) time.Time

ToTimezone return target timezone datetime if timezone exist

Types

type GMT

type GMT time.Time

func (GMT) Add

func (gmt GMT) Add(duration time.Duration) GMT

func (GMT) Format

func (gmt GMT) Format(layout string) string

func (GMT) MarshalJSON

func (gmt GMT) MarshalJSON() ([]byte, error)

func (GMT) Scan

func (gmt GMT) Scan(value interface{}) error

func (GMT) Sub

func (gmt GMT) Sub(gmt2 GMT) time.Duration

func (*GMT) UnmarshalJSON

func (gmt *GMT) UnmarshalJSON(data []byte) error

func (GMT) Value

func (gmt GMT) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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