timeutil

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package timeutil contains some utility functions regarding time operations

Index

Constants

View Source
const FormatMySQLDate = "2006-01-02"
View Source
const FormatMySQLDateTime = "2006-01-02 15:04:05.999999"
View Source
const FormatMySQLDateTimeMicroseconds = "2006-01-02 15:04:05.000000"
View Source
const FormatMySQLDateTimeMilliseconds = "2006-01-02 15:04:05.000"

Variables

This section is empty.

Functions

func AddMonths added in v1.0.1

func AddMonths(t time.Time, d int) time.Time

AddMonths returns the time corresponding to adding the given number of months to t. For example, AddMonths(t, 1) applied to January 1, 2011 returns February 1, 2010.

AddMonths does not normalizes its result as per AddDate. So, for example, adding one month to October 31 yields November 30. (AddDate returns Normalized form of November 31 which is December 1)

func CurrentTimeStamp

func CurrentTimeStamp(nano ...bool) int64

CurrentTimeStamp gets current timestamp in int64

func CurrentTimeStampStr

func CurrentTimeStampStr(nano ...bool) string

CurrentTimeStampStr gets current timestamp in string

func GetCurrentTimeStampMilli

func GetCurrentTimeStampMilli() int64

GetCurrentTimeStampMilli gets current timestamp in millis second in int64

func GetEndOfNatureMonth

func GetEndOfNatureMonth(timeStamp int64) (t time.Time)

GetEndOfNatureMonth get the end time of the nature month the given time stamp belongs to

func GetEndOfNatureWeek

func GetEndOfNatureWeek(timeStamp int64) (t time.Time)

GetEndOfNatureWeek get the end time of the nature week the given time stamp belongs to

func GetStartOfNatureMonth

func GetStartOfNatureMonth(timeStamp int64) (t time.Time)

GetStartOfNatureMonth get the start time of the nature month the given time stamp belongs to

func GetStartOfNatureWeek

func GetStartOfNatureWeek(timeStamp int64) (t time.Time)

GetStartOfNatureWeek get the start time of the nature week the given time stamp belongs to

func GetTimeStamp

func GetTimeStamp(year, month, day int, nano ...bool) int64

GetTimeStamp get timestamp in int64 by year, month and day.

func GetTimeStampFromTime

func GetTimeStampFromTime(t time.Time) int64

Get timestamp from time.Time in millis second in int64

func GetTimezoneLocation added in v1.0.4

func GetTimezoneLocation(timezone string) (*time.Location, error)

func NowUTC

func NowUTC(addDuration ...time.Duration) time.Time

NowUTC returns current UTC time with optional duration addition

func ParseDateMySQL

func ParseDateMySQL(mySQLDateStr string) (t time.Time, err error)

ParseDateMySQL parses a MySQL formatted date string into time.

func ParseDateTimeISO8601

func ParseDateTimeISO8601(dateTimeStr string) (t time.Time, err error)

ParseDateTimeISO8601 parses a ISO8601 formatted datetime string into time.

func ParseDateTimeMySQL

func ParseDateTimeMySQL(mySQLDateTimeStr string) (t time.Time, err error)

ParseDateTimeMySQL parses a MySQL formatted datetime string into time.

func ParseTimeStamp

func ParseTimeStamp(timeStamp int64) (t time.Time)

ParseTimeStamp parses a timestamp given in seconds, milliseconds or nanoseconds into time.

func ParseToTimeStamp

func ParseToTimeStamp(dateTimeStr string) (timeStamp int64, err error)

func UniqueIDAcrossProcessNow

func UniqueIDAcrossProcessNow() int64

UniqueIDAcrossProcessNow returns a unique ID across all processes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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