time

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFormat       = "2006-01-02 15:04:05"
	DateFormat          = "2006-01-02"
	FormattedDateFormat = "Jan 2, 2006"
	TimeFormat          = "15:04:05"
	HourMinuteFormat    = "15:04"
	HourFormat          = "15"
	DayDateTimeFormat   = "Mon, Aug 2, 2006 3:04 PM"
	CookieFormat        = "Monday, 02-Jan-2006 15:04:05 MST"
	RFC822Format        = "Mon, 02 Jan 06 15:04:05 -0700"
	RFC1036Format       = "Mon, 02 Jan 06 15:04:05 -0700"
	RFC2822Format       = "Mon, 02 Jan 2006 15:04:05 -0700"
	RFC3339Format       = "2006-01-02T15:04:05-07:00"
	RSSFormat           = "Mon, 02 Jan 2006 15:04:05 -0700"
)

Represents the different string formats for dates

Variables

This section is empty.

Functions

func After

func After(d time.Duration) <-chan time.Time

After will be behave like time.After unless time has been frozen If time is frozen it will add the expected delay and immediately send the frozen time on the returned channel

func Freeze

func Freeze(time time.Time)

Freeze allows time to be frozen to facilitate testing

func GetEndOfDayMillis

func GetEndOfDayMillis(thisTime time.Time, timeZoneOffset int) int64

GetEndOfDayMillis is a convenience method to get milliseconds since epoch for provided date's end of day

func GetMillis

func GetMillis() int64

GetMillis is a convenience method to get milliseconds since epoch.

func GetMillisForTime

func GetMillisForTime(thisTime time.Time) int64

GetMillisForTime is a convenience method to get milliseconds since epoch for provided Times.

func GetStartOfDayMillis

func GetStartOfDayMillis(thisTime time.Time, timeZoneOffset int) int64

GetStartOfDayMillis is a convenience method to get milliseconds since epoch for provided date's start of day

func IsTimeFrozen

func IsTimeFrozen() bool

IsTimeFrozen allows checking if time has been frozen

func NowStr

func NowStr() string

func PadDateStringZeros

func PadDateStringZeros(dateString string) string

PadDateStringZeros is a convenience method to pad 2 digit date parts with zeros to meet ISO 8601 format

func ParseDuration

func ParseDuration(v string) time.Duration

func Sleep

func Sleep(d time.Duration)

Sleep will be behave like time.Sleep unless time has been frozen If time is frozen it will add the expected sleep delay and return immediately

func Tick

func Tick(d time.Duration) <-chan time.Time

Tick will be behave like time.Tick unless time has been frozen If time is frozen it will tick normally but the date will be based on the frozen date

func UnFreeze

func UnFreeze()

UnFreeze returns time to normal operation

Types

type Filter

type Filter func(*Time) bool

Filter represents a predicate used for filtering diffs

type Time

type Time struct {
	time.Time
	// contains filtered or unexported fields
}

Provides a simple api extension for Times.

func Create

func Create(y int, mon time.Month, d, h, m, s, ns int, location string) (*Time, *errorAVA.Error)

Create returns a new pointer to Times instance from a specific date and time. If the location is invalid, it returns an ErrorAVA instead.

func CreateFromDate

func CreateFromDate(y int, mon time.Month, d int, location string) (*Time, *errorAVA.Error)

CreateFromDate returns a new pointer to a Times instance from just a date. The time portion is set to now. If the location is invalid, it returns an ErrorAVA instead.

func CreateFromFormat

func CreateFromFormat(layout, value string, location string) (*Time, *errorAVA.Error)

CreateFromFormat returns a new pointer to a Times instance from a specific format. If the location is invalid, it returns an ErrorAVA instead.

func CreateFromMonthAndYear

func CreateFromMonthAndYear(y int, mon time.Month, location string) (*Time, *errorAVA.Error)

CreateFromMonthAndYear returns a new pointer to a Times instance from a specific month and year. If the location is invalid, it returns an ErrorAVA instead.

func CreateFromTime

func CreateFromTime(h, m, s, ns int, location string) (*Time, *errorAVA.Error)

CreateFromTime returns a new pointer to a Times instance from just a date. The time portion is set to now. If the locations is invalid, it returns an ErrorAVA instead.

func CreateFromTimestamp

func CreateFromTimestamp(timestamp int64, location string) (*Time, *errorAVA.Error)

CreateFromTimestamp returns a new pointer to a Times instance from a timestamp. If the location is invalid, it returns an ErrorAVA instead.

func CreateFromTimestampUTC

func CreateFromTimestampUTC(timestamp int64) (*Time, *errorAVA.Error)

CreateFromTimestampUTC returns a new pointer to a Times instance from an UTC timestamp. If the location is invalid, it returns an ErrorAVA instead.

func MaxValue

func MaxValue() *Time

MaxValue returns a pointer to a new Times instance for greatest supported date

func MinValue

func MinValue() *Time

MinValue returns a pointer to a new Times instance for lowest supported date

func NewTime

func NewTime(t time.Time) *Time

NewTime returns a pointer to a new Times instance

func Now

func Now() *Time

Now returns a new Times instance for right now in current localtime

func NowInLocation

func NowInLocation(loc string) (*Time, *errorAVA.Error)

NowInLocation returns a new Times instance for right now in given location. The location is in IANA Times Zone database, such as "America/New_York".

func Parse

func Parse(layout, value, location string) (*Time, *errorAVA.Error)

Parser returns a pointer to a new Times instance from a string If the location is invalid, it returns an ErrorAVA instead.

func Today

func Today(location string) (*Time, *errorAVA.Error)

Today returns a pointer to a new Times instance for today If the location is invalid, it returns an ErrorAVA instead.

func Tomorrow

func Tomorrow(location string) (*Time, *errorAVA.Error)

Tomorrow returns a pointer to a new Times instance for tomorrow If the location is invalid, it returns an ErrorAVA instead.

func Yesterday

func Yesterday(location string) (*Time, *errorAVA.Error)

Yesterday returns a pointer to a new Times instance for yesterday If the location is invalid, it returns an ErrorAVA instead.

func (*Time) AddCenturies

func (c *Time) AddCenturies(cent int) *Time

AddCenturies adds centuries to the time. Positive values travels forward while negative values travels into the past

func (*Time) AddCentury

func (c *Time) AddCentury() *Time

AddCentury adds a century to the current time

func (*Time) AddDay

func (c *Time) AddDay() *Time

AddDay adds a day to the current time

func (*Time) AddDays

func (c *Time) AddDays(d int) *Time

AddDays adds a day to the current time. Positive value travels forward while negative value travels into the past

func (*Time) AddHour

func (c *Time) AddHour() *Time

AddHour adds an hour to the current time

func (*Time) AddHours

func (c *Time) AddHours(h int) *Time

AddHours adds an hour to the current time. Positive value travels forward while negative value travels into the past

func (*Time) AddMinute

func (c *Time) AddMinute() *Time

AddMinute adds a minute to the current time

func (*Time) AddMinutes

func (c *Time) AddMinutes(m int) *Time

AddMinutes adds minutes to the current time. Positive value travels forward while negative value travels into the past.

func (*Time) AddMonth

func (c *Time) AddMonth() *Time

AddMonth adds a month to the current time

func (*Time) AddMonthNoOverflow

func (c *Time) AddMonthNoOverflow() *Time

AddMonthNoOverflow adds a month with no overflow to the current time

func (*Time) AddMonths

func (c *Time) AddMonths(m int) *Time

AddMonths adds months to the current time. Positive value travels forward while negative values travels into the past

func (*Time) AddMonthsNoOverflow

func (c *Time) AddMonthsNoOverflow(m int) *Time

AddMonthsNoOverflow adds a month to the current time, not overflowing in case the destination month has less days than the current one. Positive value travels forward while negative value travels into the past.

func (*Time) AddQuarter

func (c *Time) AddQuarter() *Time

AddQuarter adds a quarter to the current time

func (*Time) AddQuarters

func (c *Time) AddQuarters(q int) *Time

AddQuarters adds quarters to the current time. Positive values travel forward while negative values travel into the past

func (*Time) AddSecond

func (c *Time) AddSecond() *Time

AddSecond adds a second to the time

func (*Time) AddSeconds

func (c *Time) AddSeconds(s int) *Time

AddSeconds adds seconds to the current time. Positive values travels forward while negative values travels into the past.

func (*Time) AddWeek

func (c *Time) AddWeek() *Time

AddWeek adds a week to the current time

func (*Time) AddWeekday

func (c *Time) AddWeekday() *Time

AddWeekday adds a weekday to the current time

func (*Time) AddWeekdays

func (c *Time) AddWeekdays(wd int) *Time

AddWeekdays adds a weekday to the current time. Positive value travels forward while negative value travels into the past

func (*Time) AddWeeks

func (c *Time) AddWeeks(w int) *Time

AddWeeks adds a week to the current time. Positive value travels forward while negative value travels into the past.

func (*Time) AddYear

func (c *Time) AddYear() *Time

AddYear adds a year to the current time

func (*Time) AddYears

func (c *Time) AddYears(y int) *Time

AddYears adds a year to the current time. Positive values travel forward while negative values travel into the past

func (*Time) After

func (c *Time) After(u time.Time) bool

func (*Time) Age

func (c *Time) Age() int

Age gets the age from the current instance time to now

func (*Time) AtomString

func (c *Time) AtomString() string

AtomString formats the current time to a Atom date format

func (*Time) Average

func (c *Time) Average(timeAVA *Time) *Time

Average returns the average between a given Times date and the current date

func (*Time) Between

func (c *Time) Between(a, b *Time, eq bool) bool

Between determines if the current instance is between two others eq Indicates if a > and < comparison should be used or <= or >=

func (*Time) Clock

func (c *Time) Clock() (hour, min, sec int)

Clock returns the hour, minute, and second within the day specified by t.

func (*Time) Closest

func (c *Time) Closest(a, b *Time) *Time

Closest returns the closest date from the current time

func (*Time) CookieString

func (c *Time) CookieString() string

CookieString formats the current time to a Cookie date format

func (*Time) Copy

func (c *Time) Copy() *Time

Copy returns a new copy of the current Times instance

func (*Time) Date

func (c *Time) Date() (year int, month time.Month, day int)

func (*Time) DateString

func (c *Time) DateString() string

DateString return the current time in Y-m-d format

func (*Time) DateTimeString

func (c *Time) DateTimeString() string

DateTimeString returns the current time in Y-m-d hh:mm:ss format

func (*Time) DayDateTimeString

func (c *Time) DayDateTimeString() string

DayDateTimeString returns the current time with a day, date and time format

func (*Time) DaysInMonth

func (c *Time) DaysInMonth() int

DaysInMonth returns the number of days in the month

func (*Time) DaysInYear

func (c *Time) DaysInYear() int

DaysInYear returns the number of days in the year

func (*Time) DiffDurationInString

func (c *Time) DiffDurationInString(timeAVA *Time) string

DiffDurationInString returns the duration difference in string format

func (*Time) DiffFiltered

func (c *Time) DiffFiltered(duration time.Duration, f Filter, timeAVA *Time, abs bool) int64

DiffFiltered returns the difference by the given duration using a filter

func (*Time) DiffInDays

func (c *Time) DiffInDays(timeAVA *Time, abs bool) int64

DiffInDays returns the difference in days

func (*Time) DiffInDaysFiltered

func (c *Time) DiffInDaysFiltered(f Filter, timeAVA *Time, abs bool) int64

DiffInDaysFiltered returns the difference in days using a filter

func (*Time) DiffInHours

func (c *Time) DiffInHours(d *Time, abs bool) int64

DiffInHours returns the difference in hours

func (*Time) DiffInHoursFiltered

func (c *Time) DiffInHoursFiltered(f Filter, timeAVA *Time, abs bool) int64

DiffInHoursFiltered returns the difference in hours using a filter

func (*Time) DiffInMinutes

func (c *Time) DiffInMinutes(d *Time, abs bool) int64

DiffInMinutes returns the difference in minutes

func (*Time) DiffInMonths

func (c *Time) DiffInMonths(timeAVA *Time, abs bool) int64

DiffInMonths returns the difference in months

func (*Time) DiffInNights

func (c *Time) DiffInNights(timeAVA *Time, abs bool) int64

DiffInNights returns the difference in nights

func (*Time) DiffInSeconds

func (c *Time) DiffInSeconds(timeAVA *Time, abs bool) int64

DiffInSeconds returns the difference in seconds

func (*Time) DiffInWeekdays

func (c *Time) DiffInWeekdays(timeAVA *Time, abs bool) int64

DiffInWeekdays returns the difference in weekdays

func (*Time) DiffInWeekendDays

func (c *Time) DiffInWeekendDays(timeAVA *Time, abs bool) int64

DiffInWeekendDays returns the difference in weekend days using a filter

func (*Time) DiffInWeeks

func (c *Time) DiffInWeeks(timeAVA *Time, abs bool) int64

DiffInWeeks returns the difference in weeks

func (*Time) DiffInYears

func (c *Time) DiffInYears(timeAVA *Time, abs bool) int64

DiffInYears returns the difference in years

func (*Time) EndOfCentury

func (c *Time) EndOfCentury() *Time

EndOfCentury returns the date of the end of the century at 23:59:59

func (*Time) EndOfDay

func (c *Time) EndOfDay() *Time

EndOfDay returns the time at 23:59:59 of the same day

func (*Time) EndOfDecade

func (c *Time) EndOfDecade() *Time

EndOfDecade returns the date at the end of the decade and time at 23:59:59

func (*Time) EndOfMonth

func (c *Time) EndOfMonth() *Time

EndOfMonth returns the date at the end of the month and time at 23:59:59

func (*Time) EndOfQuarter

func (c *Time) EndOfQuarter() *Time

EndOfQuarter returns the date at end of the quarter and time at 23:59:59

func (*Time) EndOfWeek

func (c *Time) EndOfWeek() *Time

EndOfWeek returns the date of the last day of the week at 23:59:59

func (*Time) EndOfYear

func (c *Time) EndOfYear() *Time

EndOfYear returns the date at end of the year and time to 23:59:59

func (*Time) Eq

func (c *Time) Eq(timeAVA *Time) bool

Eq determines if the current Times is equal to another

func (*Time) EqualTo

func (c *Time) EqualTo(timeAVA *Time) bool

EqualTo determines if the current Times is equal to another

func (*Time) Farthest

func (c *Time) Farthest(a, b *Time) *Time

Farthest returns the farthest date from the current time

func (*Time) FirstDayOfMonth

func (c *Time) FirstDayOfMonth() *Time

FirstDayOfMonth returns a new Times instance with the first day of current month

func (*Time) FirstOfMonth

func (c *Time) FirstOfMonth(wd time.Weekday) *Time

FirstOfMonth returns the first occurrence of a given day of the week in the current month

func (*Time) FirstOfQuarter

func (c *Time) FirstOfQuarter(wd time.Weekday) *Time

FirstOfQuarter returns the first occurrence of a given day of the week in the current quarter

func (*Time) FirstOfYear

func (c *Time) FirstOfYear(wd time.Weekday) *Time

FirstOfYear returns the first occurrence of a given day of the week in the current year

func (*Time) FormattedDateString

func (c *Time) FormattedDateString() string

FormattedDateString returns the current time as a readable date

func (*Time) GetTime

func (c *Time) GetTime() time.Time

func (*Time) GreaterThan

func (c *Time) GreaterThan(timeAVA *Time) bool

GreaterThan determines if the current Times is greater (after) than another

func (*Time) GreaterThanOrEqualTo

func (c *Time) GreaterThanOrEqualTo(timeAVA *Time) bool

GreaterThanOrEqualTo determines if the instance is greater (after) than or equal to another

func (*Time) Gt

func (c *Time) Gt(timeAVA *Time) bool

Gt determines if the current Times is greater (after) than another

func (*Time) Gte

func (c *Time) Gte(timeAVA *Time) bool

Gte determines if the instance is greater (after) than or equal to another

func (*Time) ISO8601String

func (c *Time) ISO8601String() string

ISO8601String returns the current time in ISO8601 format

func (*Time) In

func (c *Time) In(loc *time.Location) time.Time

func (*Time) IsCurrentMonth

func (c *Time) IsCurrentMonth() bool

IsCurrentMonth determines if the current time is in the current month

func (*Time) IsCurrentYear

func (c *Time) IsCurrentYear() bool

IsCurrentYear determines if the current time is in the current year

func (*Time) IsFriday

func (c *Time) IsFriday() bool

IsFriday checks if this day is a Friday.

func (*Time) IsFuture

func (c *Time) IsFuture() bool

IsFuture determines if the current time is in the future, ie. greater (after) than now

func (*Time) IsLastMonth

func (c *Time) IsLastMonth() bool

IsLastMonth returns true is the date is within last month

func (*Time) IsLastWeek

func (c *Time) IsLastWeek() bool

IsLastWeek returns true is the date is within last week

func (*Time) IsLeapYear

func (c *Time) IsLeapYear() bool

IsLeapYear determines if current current time is a leap year

func (*Time) IsLongYear

func (c *Time) IsLongYear() bool

IsLongYear determines if the instance is a long year

func (*Time) IsMonday

func (c *Time) IsMonday() bool

IsMonday checks if this day is a Monday.

func (*Time) IsPast

func (c *Time) IsPast() bool

IsPast determines if the current time is in the past, ie. less (before) than now

func (*Time) IsSameAs

func (c *Time) IsSameAs(format string, timeAVA *Time) bool

IsSameAs compares the formatted values of the two dates. If passed date is nil, compares against today

func (*Time) IsSameDay

func (c *Time) IsSameDay(timeAVA *Time) bool

IsSameDay checks if the passed in date is the same day as the current day. If passed date is nil, compares against today

func (*Time) IsSameMonth

func (c *Time) IsSameMonth(timeAVA *Time, sameYear bool) bool

IsSameMonth checks if the passed in date is in the same month as the current month If passed date is nil, compares against today

func (*Time) IsSameYear

func (c *Time) IsSameYear(timeAVA *Time) bool

IsSameYear checks if the passed in date is in the same year as the current time year. If passed date is nil, compares against today

func (*Time) IsSaturday

func (c *Time) IsSaturday() bool

IsSaturday checks if this day is a Saturday.

func (*Time) IsSunday

func (c *Time) IsSunday() bool

IsSunday checks if this day is a Sunday.

func (*Time) IsThursday

func (c *Time) IsThursday() bool

IsThursday checks if this day is a Thursday.

func (*Time) IsToday

func (c *Time) IsToday() bool

IsToday determines if the current time is today

func (*Time) IsTomorrow

func (c *Time) IsTomorrow() bool

IsTomorrow determines if the current time is tomorrow

func (*Time) IsTuesday

func (c *Time) IsTuesday() bool

IsTuesday checks if this day is a Tuesday.

func (*Time) IsWednesday

func (c *Time) IsWednesday() bool

IsWednesday checks if this day is a Wednesday.

func (*Time) IsWeekday

func (c *Time) IsWeekday() bool

IsWeekday determines if the current time is a weekday

func (*Time) IsWeekend

func (c *Time) IsWeekend() bool

IsWeekend determines if the current time is a weekend day

func (*Time) IsYesterday

func (c *Time) IsYesterday() bool

IsYesterday determines if the current time is yesterday

func (*Time) LastDayOfMonth

func (c *Time) LastDayOfMonth() *Time

LastDayOfMonth returns a new Times instance with the last day of current month

func (*Time) LastOfMonth

func (c *Time) LastOfMonth(wd time.Weekday) *Time

LastOfMonth returns the last occurrence of a given day of the week in the current month

func (*Time) LastOfQuarter

func (c *Time) LastOfQuarter(wd time.Weekday) *Time

LastOfQuarter returns the last occurrence of a given day of the week in the current quarter

func (*Time) LastOfYear

func (c *Time) LastOfYear(wd time.Weekday) *Time

LastOfYear returns the last occurrence of a given day of the week in the current year

func (*Time) LessThan

func (c *Time) LessThan(timeAVA *Time) bool

LessThan determines if the instance is less (before) than another

func (*Time) LessThanOrEqualTo

func (c *Time) LessThanOrEqualTo(timeAVA *Time) bool

LessThanOrEqualTo determines if the instance is less (before) or equal to another

func (*Time) Lt

func (c *Time) Lt(timeAVA *Time) bool

Lt determines if the instance is less (before) than another

func (*Time) Lte

func (c *Time) Lte(timeAVA *Time) bool

Lte determines if the instance is less (before) or equal to another

func (*Time) Max

func (c *Time) Max(timeAVA *Time) *Time

Max returns the maximum instance between a given instance and the current instance

func (*Time) Maximum

func (c *Time) Maximum(timeAVA *Time) *Time

Maximum returns the maximum instance between a given instance and the current instance

func (*Time) Min

func (c *Time) Min(timeAVA *Time) *Time

Min returns the minimum instance between a given instance and the current instance

func (*Time) Minimum

func (c *Time) Minimum(timeAVA *Time) *Time

Minimum returns the minimum instance between a given instance and the current instance

func (*Time) Nanosecond

func (c *Time) Nanosecond() int

func (*Time) Ne

func (c *Time) Ne(timeAVA *Time) bool

Ne determines if the current Times is not equal to another

func (*Time) Next

func (c *Time) Next(wd time.Weekday) *Time

Results changes the time to the next occurrence of a given day of the week

func (*Time) NextWeekday

func (c *Time) NextWeekday() *Time

NextWeekday goes forward to the next weekday

func (*Time) NextWeekendDay

func (c *Time) NextWeekendDay() *Time

NextWeekendDay goes forward to the next weekend day

func (*Time) NotEqualTo

func (c *Time) NotEqualTo(timeAVA *Time) bool

NotEqualTo determines if the current Times is not equal to another

func (*Time) NthOfMonth

func (c *Time) NthOfMonth(nth int, wd time.Weekday) *Time

NthOfMonth returns the given occurrence of a given day of the week in the current month If the calculated occurrence is outside the scope of current month, no modifications are made

func (*Time) NthOfQuarter

func (c *Time) NthOfQuarter(nth int, wd time.Weekday) *Time

NthOfQuarter returns the given occurrence of a given day of the week in the current quarter If the calculated occurrence is outside the scope of current quarter, no modifications are made

func (*Time) NthOfYear

func (c *Time) NthOfYear(nth int, wd time.Weekday) *Time

NthOfYear returns the given occurrence of a given day of the week in the current year If the calculated occurrence is outside the scope of current year, no modifications are made

func (*Time) Previous

func (c *Time) Previous(wd time.Weekday) *Time

Previous changes the time to the previous occurrence of a given day of the week

func (*Time) PreviousMonthLastDay

func (c *Time) PreviousMonthLastDay() *Time

PreviousMonthLastDay returns the last day of the previous month

func (*Time) PreviousWeekday

func (c *Time) PreviousWeekday() *Time

PreviousWeekday goes back to the previous weekday

func (*Time) PreviousWeekendDay

func (c *Time) PreviousWeekendDay() *Time

PreviousWeekendDay goes back to the previous weekend day

func (*Time) Quarter

func (c *Time) Quarter() int

Quarter gets the current quarter

func (*Time) RFC1036String

func (c *Time) RFC1036String() string

RFC1036String returns the current time in RFC 1036 format

func (*Time) RFC1123String

func (c *Time) RFC1123String() string

RFC1123String returns the current time in RFC 1123 format

func (*Time) RFC2822String

func (c *Time) RFC2822String() string

RFC2822String returns the current time in RFC 2822 format

func (*Time) RFC3339String

func (c *Time) RFC3339String() string

RFC3339String returns the current time in RFC 3339 format

func (*Time) RFC822String

func (c *Time) RFC822String() string

RFC822String returns the current time in RFC 822 format

func (*Time) RFC850String

func (c *Time) RFC850String() string

RFC850String returns the current time in RFC 850 format

func (*Time) RSSString

func (c *Time) RSSString() string

RSSString returns the current time for RSS format

func (*Time) ResetStringFormat

func (c *Time) ResetStringFormat()

ResetStringFormat changes the format to the DefaultFormat

func (*Time) SecondsSinceMidnight

func (c *Time) SecondsSinceMidnight() int

SecondsSinceMidnight returns the number of seconds since midnight.

func (*Time) SecondsUntilEndOfDay

func (c *Time) SecondsUntilEndOfDay() int

SecondsUntilEndOfDay returns the number of seconds until 23:59:59.

func (*Time) SetDate

func (c *Time) SetDate(y int, m time.Month, d int)

SetDate sets only the date of the current time

func (*Time) SetDateTime

func (c *Time) SetDateTime(y int, mon time.Month, d, h, m, s int)

SetDateTime sets the date and the time

func (*Time) SetDay

func (c *Time) SetDay(d int)

SetDay sets the day of the current time

func (*Time) SetHour

func (c *Time) SetHour(h int)

SetHour sets the hour of the current time

func (*Time) SetMinute

func (c *Time) SetMinute(m int)

SetMinute sets the minute of the current time

func (*Time) SetMonth

func (c *Time) SetMonth(m time.Month)

SetMonth sets the month of the current time

func (*Time) SetSecond

func (c *Time) SetSecond(s int)

SetSecond sets the second of the current time

func (*Time) SetStringFormat

func (c *Time) SetStringFormat(format string)

SetStringFormat formats the current time with the set format string

func (*Time) SetTimeFromTimeString

func (c *Time) SetTimeFromTimeString(timeString string) *errorAVA.Error

SetTimeFromTimeString receives a string and sets the current time It accepts the following formats: "hh:mm:ss", "hh:mm" and "hh"

func (*Time) SetTimeZone

func (c *Time) SetTimeZone(name string) *errorAVA.Error

SetTimeZone sets the location from a string If the location is invalid, it returns an ErrorAVA instead.

func (*Time) SetTimestamp

func (c *Time) SetTimestamp(sec int64)

SetTimestamp sets the current time given a timestamp

func (*Time) SetWeekEndsAt

func (c *Time) SetWeekEndsAt(wd time.Weekday)

SetWeekEndsAt sets the last day of week

func (*Time) SetWeekStartsAt

func (c *Time) SetWeekStartsAt(wd time.Weekday)

SetWeekStartsAt sets the first day of week

func (*Time) SetWeekendDays

func (c *Time) SetWeekendDays(wds []time.Weekday)

SetWeekendDays sets the weekend days

func (*Time) SetYear

func (c *Time) SetYear(y int)

SetYear sets the year of the current time

func (*Time) StartOfCentury

func (c *Time) StartOfCentury() *Time

StartOfCentury returns the date of the first day of the century at 00:00:00

func (*Time) StartOfDay

func (c *Time) StartOfDay() *Time

StartOfDay returns the time at 00:00:00 of the same day

func (*Time) StartOfDecade

func (c *Time) StartOfDecade() *Time

StartOfDecade returns the date at the first day of the decade and time at 00:00:00

func (*Time) StartOfMonth

func (c *Time) StartOfMonth() *Time

StartOfMonth returns the date on the first day of the month and the time to 00:00:00

func (*Time) StartOfQuarter

func (c *Time) StartOfQuarter() *Time

StartOfQuarter returns the date at the first day of the quarter and time at 00:00:00

func (*Time) StartOfWeek

func (c *Time) StartOfWeek() *Time

StartOfWeek returns the date of the first day of week at 00:00:00

func (*Time) StartOfYear

func (c *Time) StartOfYear() *Time

StartOfYear returns the date at the first day of the year and the time at 00:00:00

func (*Time) String

func (c *Time) String() string

String gets the current date using the previously set format

func (*Time) SubCenturies

func (c *Time) SubCenturies(cent int) *Time

SubCenturies removes centuries from the current time

func (*Time) SubCentury

func (c *Time) SubCentury() *Time

SubCentury removes a century from the current time

func (*Time) SubDay

func (c *Time) SubDay() *Time

SubDay removes a day from the current instance

func (*Time) SubDays

func (c *Time) SubDays(d int) *Time

SubDays removes days from the current time

func (*Time) SubHour

func (c *Time) SubHour() *Time

SubHour removes an hour from the current time

func (*Time) SubHours

func (c *Time) SubHours(h int) *Time

SubHours removes hours from the current time

func (*Time) SubMinute

func (c *Time) SubMinute() *Time

SubMinute removes a minute from the current time

func (*Time) SubMinutes

func (c *Time) SubMinutes(m int) *Time

SubMinutes removes minutes from the current time

func (*Time) SubMonth

func (c *Time) SubMonth() *Time

SubMonth removes a month from the current time

func (*Time) SubMonthNoOverflow

func (c *Time) SubMonthNoOverflow() *Time

SubMonthNoOverflow remove a month with no overflow from the current time

func (*Time) SubMonths

func (c *Time) SubMonths(m int) *Time

SubMonths removes months from the current time

func (*Time) SubMonthsNoOverflow

func (c *Time) SubMonthsNoOverflow(m int) *Time

SubMonthsNoOverflow removes months with no overflow from the current time

func (*Time) SubQuarter

func (c *Time) SubQuarter() *Time

SubQuarter removes a quarter from the current time

func (*Time) SubQuarters

func (c *Time) SubQuarters(q int) *Time

SubQuarters removes quarters from current time

func (*Time) SubSecond

func (c *Time) SubSecond() *Time

SubSecond removes a second from the current time

func (*Time) SubSeconds

func (c *Time) SubSeconds(s int) *Time

SubSeconds removes seconds from the current time

func (*Time) SubWeek

func (c *Time) SubWeek() *Time

SubWeek removes a week from the current time

func (*Time) SubWeekday

func (c *Time) SubWeekday() *Time

SubWeekday removes a weekday from the current time

func (*Time) SubWeekdays

func (c *Time) SubWeekdays(wd int) *Time

SubWeekdays removes a weekday from the current time

func (*Time) SubWeeks

func (c *Time) SubWeeks(w int) *Time

SubWeeks removes weeks to the current time

func (*Time) SubYear

func (c *Time) SubYear() *Time

SubYear removes a year from the current time

func (*Time) SubYears

func (c *Time) SubYears(y int) *Time

SubYears removes years from current time

func (*Time) TimeString

func (c *Time) TimeString() string

TimeString returns the current time in hh:mm:ss format

func (*Time) TimeZone

func (c *Time) TimeZone() string

TimeZone gets the current timezone

func (*Time) Timestamp

func (c *Time) Timestamp() int64

Timestamp gets the current time since January 1, 1970 UTC

func (*Time) W3CString

func (c *Time) W3CString() string

W3CString returns the current time for WWW Consortium format

func (*Time) WeekEndsAt

func (c *Time) WeekEndsAt() time.Weekday

WeekEndsAt gets the ending day of the week

func (*Time) WeekOfMonth

func (c *Time) WeekOfMonth() int

WeekOfMonth returns the week of the month

func (*Time) WeekOfYear

func (c *Time) WeekOfYear() (int, int)

WeekOfYear returns the week of the current year. This is an alias for time.ISOWeek

func (*Time) WeekStartsAt

func (c *Time) WeekStartsAt() time.Weekday

WeekStartsAt get the starting day of the week

func (*Time) WeekendDays

func (c *Time) WeekendDays() []time.Weekday

WeekendDays gets the weekend days of the week

type TimeI

type TimeI interface {
	Copy() *Time
	WeekStartsAt() time.Weekday
	WeekEndsAt() time.Weekday
	WeekendDays() []time.Weekday
	Quarter() int
	Age() int
	DaysInMonth() int
	DaysInYear() int
	WeekOfMonth() int
	WeekOfYear() (int, int)
	TimeZone() string
	Timestamp() int64
	String() string
	AddYears(y int) *Time
	AddYear() *Time
	AddQuarters(q int) *Time
	AddQuarter() *Time
	AddCenturies(cent int) *Time
	AddCentury() *Time
	AddMonths(m int) *Time
	AddMonth() *Time
	AddSeconds(s int) *Time
	AddSecond() *Time
	AddDays(d int) *Time
	AddDay() *Time
	AddWeekdays(wd int) *Time
	AddWeekday() *Time
	AddWeeks(w int) *Time
	AddWeek() *Time
	AddHours(h int) *Time
	AddHour() *Time
	AddMonthsNoOverflow(m int) *Time
	PreviousMonthLastDay() *Time
	AddMonthNoOverflow() *Time
	AddMinutes(m int) *Time
	AddMinute() *Time
	SubYear() *Time
	SubYears(y int) *Time
	SubQuarter() *Time
	SubQuarters(q int) *Time
	SubCentury() *Time
	SubCenturies(cent int) *Time
	SubMonth() *Time
	SubMonths(m int) *Time
	SubMonthNoOverflow() *Time
	SubMonthsNoOverflow(m int) *Time
	SubDay() *Time
	SubDays(d int) *Time
	SubWeekday() *Time
	SubWeekdays(wd int) *Time
	SubWeek() *Time
	SubWeeks(w int) *Time
	SubHour() *Time
	SubHours(h int) *Time
	SubMinute() *Time
	SubMinutes(m int) *Time
	SubSecond() *Time
	SubSeconds(s int) *Time
	SetYear(y int)
	SetMonth(m time.Month)
	SetDay(d int)
	SetHour(h int)
	SetMinute(m int)
	SetSecond(s int)
	SetDate(y int, m time.Month, d int)
	SetDateTime(y int, mon time.Month, d, h, m, s int)
	SetTimeFromTimeString(timeString string) *errorAVA.Error
	SetWeekEndsAt(wd time.Weekday)
	SetWeekStartsAt(wd time.Weekday)
	SetWeekendDays(wds []time.Weekday)
	SetTimestamp(sec int64)
	SetTimeZone(name string) *errorAVA.Error
	ResetStringFormat()
	SetStringFormat(format string)
	DateString() string
	FormattedDateString() string
	TimeString() string
	DateTimeString() string
	DayDateTimeString() string
	AtomString() string
	CookieString() string
	ISO8601String() string
	RFC822String() string
	RFC850String() string
	RFC1036String() string
	RFC1123String() string
	RFC2822String() string
	RFC3339String() string
	RSSString() string
	W3CString() string
	IsWeekday() bool
	IsWeekend() bool
	IsYesterday() bool
	IsToday() bool
	IsTomorrow() bool
	IsFuture() bool
	IsPast() bool
	IsLeapYear() bool
	IsLongYear() bool
	IsSameAs(format string, time *Time) bool
	IsCurrentYear() bool
	IsSameYear(time *Time) bool
	IsCurrentMonth() bool
	IsSameMonth(time *Time, sameYear bool) bool
	IsSameDay(time *Time) bool
	IsSunday() bool
	IsMonday() bool
	IsTuesday() bool
	IsWednesday() bool
	IsThursday() bool
	IsFriday() bool
	IsSaturday() bool
	IsLastWeek() bool
	IsLastMonth() bool
	Eq(time *Time) bool
	EqualTo(time *Time) bool
	Ne(time *Time) bool
	NotEqualTo(time *Time) bool
	Gt(time *Time) bool
	GreaterThan(time *Time) bool
	Gte(time *Time) bool
	GreaterThanOrEqualTo(time *Time) bool
	Lt(time *Time) bool
	LessThan(time *Time) bool
	Lte(time *Time) bool
	LessThanOrEqualTo(time *Time) bool
	Between(a, b *Time, eq bool) bool
	Closest(a, b *Time) *Time
	Farthest(a, b *Time) *Time
	Min(time *Time) *Time
	Minimum(time *Time) *Time
	Max(time *Time) *Time
	Maximum(time *Time) *Time
	DiffInYears(time *Time, abs bool) int64
	DiffInMonths(time *Time, abs bool) int64

	DiffDurationInString(time *Time) string
	DiffInWeeks(time *Time, abs bool) int64
	DiffInDays(time *Time, abs bool) int64
	DiffInNights(time *Time, abs bool) int64
	DiffInDaysFiltered(f Filter, time *Time, abs bool) int64
	DiffInHoursFiltered(f Filter, time *Time, abs bool) int64
	DiffInWeekdays(time *Time, abs bool) int64
	DiffInWeekendDays(time *Time, abs bool) int64
	DiffFiltered(duration time.Duration, f Filter, time *Time, abs bool) int64
	DiffInHours(d *Time, abs bool) int64
	DiffInMinutes(d *Time, abs bool) int64
	DiffInSeconds(time *Time, abs bool) int64
	SecondsSinceMidnight() int
	SecondsUntilEndOfDay() int
	StartOfDay() *Time
	EndOfDay() *Time
	StartOfMonth() *Time
	EndOfMonth() *Time
	StartOfQuarter() *Time
	EndOfQuarter() *Time
	StartOfYear() *Time
	EndOfYear() *Time
	StartOfDecade() *Time
	EndOfDecade() *Time
	StartOfCentury() *Time
	EndOfCentury() *Time
	StartOfWeek() *Time
	EndOfWeek() *Time
	Next(wd time.Weekday) *Time
	NextWeekday() *Time
	PreviousWeekday() *Time
	NextWeekendDay() *Time
	PreviousWeekendDay() *Time
	Previous(wd time.Weekday) *Time
	FirstOfMonth(wd time.Weekday) *Time
	LastOfMonth(wd time.Weekday) *Time
	LastDayOfMonth() *Time
	FirstDayOfMonth() *Time
	NthOfMonth(nth int, wd time.Weekday) *Time
	FirstOfQuarter(wd time.Weekday) *Time
	LastOfQuarter(wd time.Weekday) *Time
	NthOfQuarter(nth int, wd time.Weekday) *Time
	FirstOfYear(wd time.Weekday) *Time
	LastOfYear(wd time.Weekday) *Time
	NthOfYear(nth int, wd time.Weekday) *Time
	Average(time *Time) *Time
	Clock() (hour, min, sec int)
	Nanosecond() int
	Date() (year int, month time.Month, day int)
	In(loc *time.Location) time.Time
	Day() int
	Month() time.Month
	Year() int
	After(u time.Time) bool
	GetTime() time.Time
	Format(layout string) string
	Sub(u time.Time) time.Duration
	UnixNano() int64
	Location() *time.Location
	Add(d time.Duration) time.Time
	Weekday() time.Weekday
	// contains filtered or unexported methods
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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