time

package
v0.0.0-...-06dd36e Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ISO            = `2006-01-02T15:04:05.999999`
	YMD_HM         = `2006-01-02 15:04`
	YMD_HMS        = `2006-01-02 15:04:05`
	YMD            = `2006-01-02`
	FILE           = `20060102_150405`
	HUMAN_DATETIME = `2-Jan-2006 15:04:05`
	HUMAN_DATE     = `2 Jan 2006`
	YY             = `06`
	YMDH           = `20060102.15`
	YMDHM          = `20060102.1504`
	HMS            = `150405`
)

Variables

View Source
var EMPTY = time.Time{}

Functions

func Age

func Age(birthdate time.Time) float64

Age returns age from current date

func AgeAt

func AgeAt(birthdate, point time.Time) float64

AgeAt returns age from within 2 date

func CountDays

func CountDays(layout, dateStart, dateEnd string) (int, error)

CountDays - count days from 2 date input

func DateHhMmString

func DateHhMmString() string

DateHhMmString return current iso date and hour time.DateHhMmString()// output "20160317.1059"

func DateHhString

func DateHhString() string

DateHhString return current iso date and hour time.DateHhString() // output "20160317.10"

func DateString

func DateString() string

DateString return current iso date time.DateString()) // "2016-03-17"

func DateTimeString

func DateTimeString() string

DateTimeString return current iso date and time time.DateTimeString(time.Now()) // "2016-03-17 10:07:50"

func DayInt

func DayInt() int64

DayInt return day of current date

func Epoch

func Epoch() int64

Epoch get current unix (second) as integer

func EpochAfter

func EpochAfter(d time.Duration) int64

EpochAfter return current unix time added with a duration

func EpochAfterString

func EpochAfterString(d time.Duration) string

EpochAfterString return current unix time added with a duration

func EpochString

func EpochString() string

EpochString return current unix (second) as string

func HourInt

func HourInt() int64

HourInt return current hour

func HumanString

func HumanString() string

HumanString return current human date time.HumanString() // "17-Mar-2016 10:06"

func IsValidTimeRange

func IsValidTimeRange(start, end, check time.Time) bool

IsValidTimeRange check if time in are in the range t1, _:=time.Parse(`1992-03-23`,T.DateFormat) t2, _:=time.Parse(`2016-03-17`,T.DateFormat) time.IsValidTimeRange(t1,t2,time.Now()) // bool(false)

func IsoTime

func IsoTime() string

IsoTime return current iso time time.IsoTime() // "2016-03-17T10:07:56.418728"

func LastTwoDigitYear

func LastTwoDigitYear() string

LastTwoDigitYear return current last two digit year

func MonthInt

func MonthInt() int64

MonthInt return current month

func TimeLoadLocation

func TimeLoadLocation(timezone string) *time.Location

TimeLoadLocation load time using specific timezone

func ToDateHourString

func ToDateHourString(t time.Time) string

ToDateHourString convert time to iso date and hour:minute time.ToDateHourString(time.Now()) // "2016-03-17 10:07"

func ToDateString

func ToDateString(t time.Time) string

ToDateString convert time to iso date string time.ToDateString(time.Now()) // output "2016-03-17"

func ToDateTimeString

func ToDateTimeString(t time.Time) string

ToDateTimeString convert time to iso date and time time.ToDateTimeString(time.Now()) // "2016-03-17 10:07:50"

func ToEpoch

func ToEpoch(date string) int64

ToEpoch convert string date to epoch => '2019-01-01' -->1546300800

func ToHhMmSs

func ToHhMmSs(t time.Time) string

ToHhMmSs convert time to iso date and hourminutesecond time.ToHhMmSs(time.Now()) // "230744"

func ToHumanString

func ToHumanString(t time.Time) string

ToHumanString convert time to human date time.ToHumanString(time.Now()) // "17-Mar-2016 10:06"

func ToIsoString

func ToIsoString(t time.Time) string

ToIsoString convert time to iso formatted time string time.ToIsoString(time.Now()) // "2016-03-17T10:04:50.6489"

func UnixNanoAfter

func UnixNanoAfter(d time.Duration) int64

UnixNanoAfter get current unix nano after added with certain duration

func UnixToDateString

func UnixToDateString(epoch float64) string

UnixToDateString convert from unix to date format string

func UnixToDateTimeString

func UnixToDateTimeString(epoch float64) string

UnixToDateTimeString convert unix time to date time string

func UnixToFile

func UnixToFile(i int64) string

convert unix time to file naming

func UnixToHumanDateString

func UnixToHumanDateString(epoch float64) string

UnixToHumanDateString convert from unix to human date format

func UnixToHumanString

func UnixToHumanString(epoch float64) string

UnixToHumanString convert from unix to human format

func Weekday

func Weekday() int

Weekday return what day is it today, Sunday => 0

func WeekdayString

func WeekdayString() string

WeekdayString return day's name

func YearDayInt

func YearDayInt() int64

YearDayInt return current day of year

func YearInt

func YearInt() int64

YearInt return current year

Types

This section is empty.

Jump to

Keyboard shortcuts

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