carbon: github.com/uniplaces/carbon Index | Files | Directories

package carbon

import "github.com/uniplaces/carbon"

Package `carbon` is an extension to Go's time library based on PHP's Carbon library

Index

Package Files

carbon.go carboninterval.go translator.go

Constants

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

func After Uses

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 Uses

func Freeze(time time.Time)

Freeze allows time to be frozen to facilitate testing

func IsTimeFrozen Uses

func IsTimeFrozen() bool

IsTimeFrozen allows checking if time has been frozen

func Sleep Uses

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 Uses

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 Uses

func UnFreeze()

UnFreeze returns time to normal operation

type Carbon Uses

type Carbon struct {
    time.Time

    Translator *Translator
    // contains filtered or unexported fields
}

The Carbon type represents a Time instance. Provides a simple API extension for Time.

func Create Uses

func Create(y int, mon time.Month, d, h, m, s, ns int, location string) (*Carbon, error)

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

func CreateFromDate Uses

func CreateFromDate(y int, mon time.Month, d int, location string) (*Carbon, error)

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

func CreateFromFormat Uses

func CreateFromFormat(layout, value string, location string) (*Carbon, error)

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

func CreateFromMonthAndYear Uses

func CreateFromMonthAndYear(y int, mon time.Month, location string) (*Carbon, error)

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

func CreateFromTime Uses

func CreateFromTime(h, m, s, ns int, location string) (*Carbon, error)

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

func CreateFromTimestamp Uses

func CreateFromTimestamp(timestamp int64, location string) (*Carbon, error)

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

func CreateFromTimestampUTC Uses

func CreateFromTimestampUTC(timestamp int64) (*Carbon, error)

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

func MaxValue Uses

func MaxValue() *Carbon

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

func MinValue Uses

func MinValue() *Carbon

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

func NewCarbon Uses

func NewCarbon(t time.Time) *Carbon

NewCarbon returns a pointer to a new Carbon instance

func Now Uses

func Now() *Carbon

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

func NowInLocation Uses

func NowInLocation(loc string) (*Carbon, error)

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

func Parse Uses

func Parse(layout, value, location string) (*Carbon, error)

Parse returns a pointer to a new carbon instance from a string If the location is invalid, it returns an error instead.

func Today Uses

func Today(location string) (*Carbon, error)

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

func Tomorrow Uses

func Tomorrow(location string) (*Carbon, error)

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

func Yesterday Uses

func Yesterday(location string) (*Carbon, error)

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

func (*Carbon) AddCenturies Uses

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

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

func (*Carbon) AddCentury Uses

func (c *Carbon) AddCentury() *Carbon

AddCentury adds a century to the current time

func (*Carbon) AddDay Uses

func (c *Carbon) AddDay() *Carbon

AddDay adds a day to the current time

func (*Carbon) AddDays Uses

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

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

func (*Carbon) AddHour Uses

func (c *Carbon) AddHour() *Carbon

AddHour adds an hour to the current time

func (*Carbon) AddHours Uses

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

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

func (*Carbon) AddMinute Uses

func (c *Carbon) AddMinute() *Carbon

AddMinute adds a minute to the current time

func (*Carbon) AddMinutes Uses

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

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

func (*Carbon) AddMonth Uses

func (c *Carbon) AddMonth() *Carbon

AddMonth adds a month to the current time

func (*Carbon) AddMonthNoOverflow Uses

func (c *Carbon) AddMonthNoOverflow() *Carbon

AddMonthNoOverflow adds a month with no overflow to the current time

func (*Carbon) AddMonths Uses

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

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

func (*Carbon) AddMonthsNoOverflow Uses

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

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 (*Carbon) AddQuarter Uses

func (c *Carbon) AddQuarter() *Carbon

AddQuarter adds a quarter to the current time

func (*Carbon) AddQuarters Uses

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

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

func (*Carbon) AddSecond Uses

func (c *Carbon) AddSecond() *Carbon

AddSecond adds a second to the time

func (*Carbon) AddSeconds Uses

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

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

func (*Carbon) AddWeek Uses

func (c *Carbon) AddWeek() *Carbon

AddWeek adds a week to the current time

func (*Carbon) AddWeekday Uses

func (c *Carbon) AddWeekday() *Carbon

AddWeekday adds a weekday to the current time

func (*Carbon) AddWeekdays Uses

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

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

func (*Carbon) AddWeeks Uses

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

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

func (*Carbon) AddYear Uses

func (c *Carbon) AddYear() *Carbon

AddYear adds a year to the current time

func (*Carbon) AddYears Uses

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

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

func (*Carbon) Age Uses

func (c *Carbon) Age() int

Age gets the age from the current instance time to now

func (*Carbon) AtomString Uses

func (c *Carbon) AtomString() string

AtomString formats the current time to a Atom date format

func (*Carbon) Average Uses

func (c *Carbon) Average(carb *Carbon) *Carbon

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

func (*Carbon) Between Uses

func (c *Carbon) Between(a, b *Carbon, 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 (*Carbon) Closest Uses

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

Closest returns the closest date from the current time

func (*Carbon) CookieString Uses

func (c *Carbon) CookieString() string

CookieString formats the current time to a Cookie date format

func (*Carbon) Copy Uses

func (c *Carbon) Copy() *Carbon

Copy returns a new copy of the current Carbon instance

func (*Carbon) DateString Uses

func (c *Carbon) DateString() string

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

func (*Carbon) DateTimeString Uses

func (c *Carbon) DateTimeString() string

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

func (*Carbon) DayDateTimeString Uses

func (c *Carbon) DayDateTimeString() string

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

func (*Carbon) DaysInMonth Uses

func (c *Carbon) DaysInMonth() int

DaysInMonth returns the number of days in the month

func (*Carbon) DaysInYear Uses

func (c *Carbon) DaysInYear() int

DaysInYear returns the number of days in the year

func (*Carbon) DiffDurationInString Uses

func (c *Carbon) DiffDurationInString(carb *Carbon) string

DiffDurationInString returns the duration difference in string format

func (*Carbon) DiffFiltered Uses

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

DiffFiltered returns the difference by the given duration using a filter

func (*Carbon) DiffForHumans Uses

func (c *Carbon) DiffForHumans(d *Carbon, abs, absolute, short bool) (string, error)

DiffForHumans returns the difference in a human readable format in the current locale. When comparing a value in the past to default now: 1 hour ago 5 months ago When comparing a value in the future to default now: 1 hour from now 5 months from now When comparing a value in the past to another value: 1 hour before 5 months before When comparing a value in the future to another value: 1 hour after 5 months after

func (*Carbon) DiffInDays Uses

func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64

DiffInDays returns the difference in days

func (*Carbon) DiffInDaysFiltered Uses

func (c *Carbon) DiffInDaysFiltered(f Filter, carb *Carbon, abs bool) int64

DiffInDaysFiltered returns the difference in days using a filter

func (*Carbon) DiffInHours Uses

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

DiffInHours returns the difference in hours

func (*Carbon) DiffInHoursFiltered Uses

func (c *Carbon) DiffInHoursFiltered(f Filter, carb *Carbon, abs bool) int64

DiffInHoursFiltered returns the difference in hours using a filter

func (*Carbon) DiffInMinutes Uses

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

DiffInMinutes returns the difference in minutes

func (*Carbon) DiffInMonths Uses

func (c *Carbon) DiffInMonths(carb *Carbon, abs bool) int64

DiffInMonths returns the difference in months

func (*Carbon) DiffInNights Uses

func (c *Carbon) DiffInNights(carb *Carbon, abs bool) int64

DiffInNights returns the difference in nights

func (*Carbon) DiffInSeconds Uses

func (c *Carbon) DiffInSeconds(carb *Carbon, abs bool) int64

DiffInSeconds returns the difference in seconds

func (*Carbon) DiffInWeekdays Uses

func (c *Carbon) DiffInWeekdays(carb *Carbon, abs bool) int64

DiffInWeekdays returns the difference in weekdays

func (*Carbon) DiffInWeekendDays Uses

func (c *Carbon) DiffInWeekendDays(carb *Carbon, abs bool) int64

DiffInWeekendDays returns the difference in weekend days using a filter

func (*Carbon) DiffInWeeks Uses

func (c *Carbon) DiffInWeeks(carb *Carbon, abs bool) int64

DiffInWeeks returns the difference in weeks

func (*Carbon) DiffInYears Uses

func (c *Carbon) DiffInYears(carb *Carbon, abs bool) int64

DiffInYears returns the difference in years

func (*Carbon) EndOfCentury Uses

func (c *Carbon) EndOfCentury() *Carbon

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

func (*Carbon) EndOfDay Uses

func (c *Carbon) EndOfDay() *Carbon

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

func (*Carbon) EndOfDecade Uses

func (c *Carbon) EndOfDecade() *Carbon

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

func (*Carbon) EndOfMonth Uses

func (c *Carbon) EndOfMonth() *Carbon

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

func (*Carbon) EndOfQuarter Uses

func (c *Carbon) EndOfQuarter() *Carbon

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

func (*Carbon) EndOfWeek Uses

func (c *Carbon) EndOfWeek() *Carbon

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

func (*Carbon) EndOfYear Uses

func (c *Carbon) EndOfYear() *Carbon

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

func (*Carbon) Eq Uses

func (c *Carbon) Eq(carb *Carbon) bool

Eq determines if the current carbon is equal to another

func (*Carbon) EqualTo Uses

func (c *Carbon) EqualTo(carb *Carbon) bool

EqualTo determines if the current carbon is equal to another

func (*Carbon) Farthest Uses

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

Farthest returns the farthest date from the current time

func (*Carbon) FirstDayOfMonth Uses

func (c *Carbon) FirstDayOfMonth() *Carbon

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

func (*Carbon) FirstOfMonth Uses

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

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

func (*Carbon) FirstOfQuarter Uses

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

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

func (*Carbon) FirstOfYear Uses

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

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

func (*Carbon) FormattedDateString Uses

func (c *Carbon) FormattedDateString() string

FormattedDateString returns the current time as a readable date

func (*Carbon) GetLocale Uses

func (c *Carbon) GetLocale() string

GetLocale returns locale of the Translator of Carbon

func (*Carbon) GetTranslator Uses

func (c *Carbon) GetTranslator() (*Translator, error)

GetTranslator returns Translator inside a Carbon instance if exist, otherwise it creates a new Translator with "en" as default locale

func (*Carbon) GreaterThan Uses

func (c *Carbon) GreaterThan(carb *Carbon) bool

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

func (*Carbon) GreaterThanOrEqualTo Uses

func (c *Carbon) GreaterThanOrEqualTo(carb *Carbon) bool

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

func (*Carbon) Gt Uses

func (c *Carbon) Gt(carb *Carbon) bool

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

func (*Carbon) Gte Uses

func (c *Carbon) Gte(carb *Carbon) bool

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

func (*Carbon) ISO8601String Uses

func (c *Carbon) ISO8601String() string

ISO8601String returns the current time in ISO8601 format

func (*Carbon) IsCurrentMonth Uses

func (c *Carbon) IsCurrentMonth() bool

IsCurrentMonth determines if the current time is in the current month

func (*Carbon) IsCurrentYear Uses

func (c *Carbon) IsCurrentYear() bool

IsCurrentYear determines if the current time is in the current year

func (*Carbon) IsFriday Uses

func (c *Carbon) IsFriday() bool

IsFriday checks if this day is a Friday.

func (*Carbon) IsFuture Uses

func (c *Carbon) IsFuture() bool

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

func (*Carbon) IsLastMonth Uses

func (c *Carbon) IsLastMonth() bool

IsLastMonth returns true is the date is within last month

func (*Carbon) IsLastWeek Uses

func (c *Carbon) IsLastWeek() bool

IsLastWeek returns true is the date is within last week

func (*Carbon) IsLeapYear Uses

func (c *Carbon) IsLeapYear() bool

IsLeapYear determines if current current time is a leap year

func (*Carbon) IsLongYear Uses

func (c *Carbon) IsLongYear() bool

IsLongYear determines if the instance is a long year

func (*Carbon) IsMonday Uses

func (c *Carbon) IsMonday() bool

IsMonday checks if this day is a Monday.

func (*Carbon) IsPast Uses

func (c *Carbon) IsPast() bool

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

func (*Carbon) IsSameAs Uses

func (c *Carbon) IsSameAs(format string, carb *Carbon) bool

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

func (*Carbon) IsSameDay Uses

func (c *Carbon) IsSameDay(carb *Carbon) 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 (*Carbon) IsSameMonth Uses

func (c *Carbon) IsSameMonth(carb *Carbon, 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 (*Carbon) IsSameYear Uses

func (c *Carbon) IsSameYear(carb *Carbon) 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 (*Carbon) IsSaturday Uses

func (c *Carbon) IsSaturday() bool

IsSaturday checks if this day is a Saturday.

func (*Carbon) IsSunday Uses

func (c *Carbon) IsSunday() bool

IsSunday checks if this day is a Sunday.

func (*Carbon) IsThursday Uses

func (c *Carbon) IsThursday() bool

IsThursday checks if this day is a Thursday.

func (*Carbon) IsToday Uses

func (c *Carbon) IsToday() bool

IsToday determines if the current time is today

func (*Carbon) IsTomorrow Uses

func (c *Carbon) IsTomorrow() bool

IsTomorrow determines if the current time is tomorrow

func (*Carbon) IsTuesday Uses

func (c *Carbon) IsTuesday() bool

IsTuesday checks if this day is a Tuesday.

func (*Carbon) IsWednesday Uses

func (c *Carbon) IsWednesday() bool

IsWednesday checks if this day is a Wednesday.

func (*Carbon) IsWeekday Uses

func (c *Carbon) IsWeekday() bool

IsWeekday determines if the current time is a weekday

func (*Carbon) IsWeekend Uses

func (c *Carbon) IsWeekend() bool

IsWeekend determines if the current time is a weekend day

func (*Carbon) IsYesterday Uses

func (c *Carbon) IsYesterday() bool

IsYesterday determines if the current time is yesterday

func (*Carbon) LastDayOfMonth Uses

func (c *Carbon) LastDayOfMonth() *Carbon

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

func (*Carbon) LastOfMonth Uses

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

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

func (*Carbon) LastOfQuarter Uses

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

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

func (*Carbon) LastOfYear Uses

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

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

func (*Carbon) LessThan Uses

func (c *Carbon) LessThan(carb *Carbon) bool

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

func (*Carbon) LessThanOrEqualTo Uses

func (c *Carbon) LessThanOrEqualTo(carb *Carbon) bool

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

func (*Carbon) Lt Uses

func (c *Carbon) Lt(carb *Carbon) bool

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

func (*Carbon) Lte Uses

func (c *Carbon) Lte(carb *Carbon) bool

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

func (*Carbon) Max Uses

func (c *Carbon) Max(carb *Carbon) *Carbon

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

func (*Carbon) Maximum Uses

func (c *Carbon) Maximum(carb *Carbon) *Carbon

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

func (*Carbon) Min Uses

func (c *Carbon) Min(carb *Carbon) *Carbon

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

func (*Carbon) Minimum Uses

func (c *Carbon) Minimum(carb *Carbon) *Carbon

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

func (*Carbon) Ne Uses

func (c *Carbon) Ne(carb *Carbon) bool

Ne determines if the current carbon is not equal to another

func (*Carbon) Next Uses

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

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

func (*Carbon) NextWeekday Uses

func (c *Carbon) NextWeekday() *Carbon

NextWeekday goes forward to the next weekday

func (*Carbon) NextWeekendDay Uses

func (c *Carbon) NextWeekendDay() *Carbon

NextWeekendDay goes forward to the next weekend day

func (*Carbon) NotEqualTo Uses

func (c *Carbon) NotEqualTo(carb *Carbon) bool

NotEqualTo determines if the current carbon is not equal to another

func (*Carbon) NthOfMonth Uses

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

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 (*Carbon) NthOfQuarter Uses

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

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 (*Carbon) NthOfYear Uses

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

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 (*Carbon) Previous Uses

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

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

func (*Carbon) PreviousMonthLastDay Uses

func (c *Carbon) PreviousMonthLastDay() *Carbon

PreviousMonthLastDay returns the last day of the previous month

func (*Carbon) PreviousWeekday Uses

func (c *Carbon) PreviousWeekday() *Carbon

PreviousWeekday goes back to the previous weekday

func (*Carbon) PreviousWeekendDay Uses

func (c *Carbon) PreviousWeekendDay() *Carbon

PreviousWeekendDay goes back to the previous weekend day

func (*Carbon) Quarter Uses

func (c *Carbon) Quarter() int

Quarter gets the current quarter

func (*Carbon) RFC1036String Uses

func (c *Carbon) RFC1036String() string

RFC1036String returns the current time in RFC 1036 format

func (*Carbon) RFC1123String Uses

func (c *Carbon) RFC1123String() string

RFC1123String returns the current time in RFC 1123 format

func (*Carbon) RFC2822String Uses

func (c *Carbon) RFC2822String() string

RFC2822String returns the current time in RFC 2822 format

func (*Carbon) RFC3339String Uses

func (c *Carbon) RFC3339String() string

RFC3339String returns the current time in RFC 3339 format

func (*Carbon) RFC822String Uses

func (c *Carbon) RFC822String() string

RFC822String returns the current time in RFC 822 format

func (*Carbon) RFC850String Uses

func (c *Carbon) RFC850String() string

RFC850String returns the current time in RFC 850 format

func (*Carbon) RSSString Uses

func (c *Carbon) RSSString() string

RSSString returns the current time for RSS format

func (*Carbon) ResetStringFormat Uses

func (c *Carbon) ResetStringFormat()

ResetStringFormat changes the format to the DefaultFormat

func (*Carbon) SecondsSinceMidnight Uses

func (c *Carbon) SecondsSinceMidnight() int

SecondsSinceMidnight returns the number of seconds since midnight.

func (*Carbon) SecondsUntilEndOfDay Uses

func (c *Carbon) SecondsUntilEndOfDay() int

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

func (*Carbon) SetDate Uses

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

SetDate sets only the date of the current time

func (*Carbon) SetDateTime Uses

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

SetDateTime sets the date and the time

func (*Carbon) SetDay Uses

func (c *Carbon) SetDay(d int)

SetDay sets the day of the current time

func (*Carbon) SetHour Uses

func (c *Carbon) SetHour(h int)

SetHour sets the hour of the current time

func (*Carbon) SetLocale Uses

func (c *Carbon) SetLocale(l string) error

SetLocale sets locale for the Translator of Carbon

func (*Carbon) SetMinute Uses

func (c *Carbon) SetMinute(m int)

SetMinute sets the minute of the current time

func (*Carbon) SetMonth Uses

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

SetMonth sets the month of the current time

func (*Carbon) SetSecond Uses

func (c *Carbon) SetSecond(s int)

SetSecond sets the second of the current time

func (*Carbon) SetStringFormat Uses

func (c *Carbon) SetStringFormat(format string)

SetStringFormat formats the current time with the set format string

func (*Carbon) SetTimeFromTimeString Uses

func (c *Carbon) SetTimeFromTimeString(timeString string) error

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

func (*Carbon) SetTimeZone Uses

func (c *Carbon) SetTimeZone(name string) error

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

func (*Carbon) SetTimestamp Uses

func (c *Carbon) SetTimestamp(sec int64)

SetTimestamp sets the current time given a timestamp

func (*Carbon) SetTranslator Uses

func (c *Carbon) SetTranslator(t *Translator)

SetTranslator sets the Translator inside a Carbon instance

func (*Carbon) SetWeekEndsAt Uses

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

SetWeekEndsAt sets the last day of week

func (*Carbon) SetWeekStartsAt Uses

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

SetWeekStartsAt sets the first day of week

func (*Carbon) SetWeekendDays Uses

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

SetWeekendDays sets the weekend days

func (*Carbon) SetYear Uses

func (c *Carbon) SetYear(y int)

SetYear sets the year of the current time

func (*Carbon) StartOfCentury Uses

func (c *Carbon) StartOfCentury() *Carbon

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

func (*Carbon) StartOfDay Uses

func (c *Carbon) StartOfDay() *Carbon

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

func (*Carbon) StartOfDecade Uses

func (c *Carbon) StartOfDecade() *Carbon

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

func (*Carbon) StartOfMonth Uses

func (c *Carbon) StartOfMonth() *Carbon

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

func (*Carbon) StartOfQuarter Uses

func (c *Carbon) StartOfQuarter() *Carbon

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

func (*Carbon) StartOfWeek Uses

func (c *Carbon) StartOfWeek() *Carbon

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

func (*Carbon) StartOfYear Uses

func (c *Carbon) StartOfYear() *Carbon

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

func (*Carbon) String Uses

func (c *Carbon) String() string

String gets the current date using the previously set format

func (*Carbon) SubCenturies Uses

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

SubCenturies removes centuries from the current time

func (*Carbon) SubCentury Uses

func (c *Carbon) SubCentury() *Carbon

SubCentury removes a century from the current time

func (*Carbon) SubDay Uses

func (c *Carbon) SubDay() *Carbon

SubDay removes a day from the current instance

func (*Carbon) SubDays Uses

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

SubDays removes days from the current time

func (*Carbon) SubHour Uses

func (c *Carbon) SubHour() *Carbon

SubHour removes an hour from the current time

func (*Carbon) SubHours Uses

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

SubHours removes hours from the current time

func (*Carbon) SubMinute Uses

func (c *Carbon) SubMinute() *Carbon

SubMinute removes a minute from the current time

func (*Carbon) SubMinutes Uses

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

SubMinutes removes minutes from the current time

func (*Carbon) SubMonth Uses

func (c *Carbon) SubMonth() *Carbon

SubMonth removes a month from the current time

func (*Carbon) SubMonthNoOverflow Uses

func (c *Carbon) SubMonthNoOverflow() *Carbon

SubMonthNoOverflow remove a month with no overflow from the current time

func (*Carbon) SubMonths Uses

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

SubMonths removes months from the current time

func (*Carbon) SubMonthsNoOverflow Uses

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

SubMonthsNoOverflow removes months with no overflow from the current time

func (*Carbon) SubQuarter Uses

func (c *Carbon) SubQuarter() *Carbon

SubQuarter removes a quarter from the current time

func (*Carbon) SubQuarters Uses

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

SubQuarters removes quarters from current time

func (*Carbon) SubSecond Uses

func (c *Carbon) SubSecond() *Carbon

SubSecond removes a second from the current time

func (*Carbon) SubSeconds Uses

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

SubSeconds removes seconds from the current time

func (*Carbon) SubWeek Uses

func (c *Carbon) SubWeek() *Carbon

SubWeek removes a week from the current time

func (*Carbon) SubWeekday Uses

func (c *Carbon) SubWeekday() *Carbon

SubWeekday removes a weekday from the current time

func (*Carbon) SubWeekdays Uses

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

SubWeekdays removes a weekday from the current time

func (*Carbon) SubWeeks Uses

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

SubWeeks removes weeks to the current time

func (*Carbon) SubYear Uses

func (c *Carbon) SubYear() *Carbon

SubYear removes a year from the current time

func (*Carbon) SubYears Uses

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

SubYears removes years from current time

func (*Carbon) TimeString Uses

func (c *Carbon) TimeString() string

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

func (*Carbon) TimeZone Uses

func (c *Carbon) TimeZone() string

TimeZone gets the current timezone

func (*Carbon) Timestamp Uses

func (c *Carbon) Timestamp() int64

Timestamp gets the current time since January 1, 1970 UTC

func (*Carbon) W3CString Uses

func (c *Carbon) W3CString() string

W3CString returns the current time for WWW Consortium format

func (*Carbon) WeekEndsAt Uses

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

WeekEndsAt gets the ending day of the week

func (*Carbon) WeekOfMonth Uses

func (c *Carbon) WeekOfMonth() int

WeekOfMonth returns the week of the month

func (*Carbon) WeekOfYear Uses

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

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

func (*Carbon) WeekStartsAt Uses

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

WeekStartsAt get the starting day of the week

func (*Carbon) WeekendDays Uses

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

WeekendDays gets the weekend days of the week

type CarbonInterval Uses

type CarbonInterval struct {
    Start *Carbon
    End   *Carbon
}

CarbonInterval represents an interval between two carbons.

func NewCarbonInterval Uses

func NewCarbonInterval(start, end *Carbon) (*CarbonInterval, error)

NewCarbonInterval returns a pointer to a new CarbonInterval instance

func (*CarbonInterval) DiffInHours Uses

func (ci *CarbonInterval) DiffInHours() int64

DiffInHours return the difference in hours between start and end date

type Filter Uses

type Filter func(*Carbon) bool

Filter represents a predicate used for filtering diffs

type Translator Uses

type Translator struct {
    // contains filtered or unexported fields
}

Translator helps to translate time based on locale

func NewTranslator Uses

func NewTranslator() *Translator

NewTranslator returns a initialized instance of Translator

func (*Translator) AssertValidLocale Uses

func (t *Translator) AssertValidLocale(l string) error

AssertValidLocale checks if the locale is valid or not

func (*Translator) GetLocale Uses

func (t *Translator) GetLocale() string

GetLocale will return locale of a Translator

func (*Translator) SetLocale Uses

func (t *Translator) SetLocale(l string) error

SetLocale will set locale on a Translator

Directories

PathSynopsis
examples
lang

Package carbon imports 8 packages (graph) and is imported by 3 packages. Updated 2019-01-16. Refresh now. Tools for package owners.