Documentation ¶
Overview ¶
Package `carbon` is an extension to Go's time library based on PHP's Carbon library
Index ¶
- Constants
- Variables
- func After(d time.Duration) <-chan time.Time
- func Freeze(time time.Time)
- func IsTimeFrozen() bool
- func Sleep(d time.Duration)
- func Tick(d time.Duration) <-chan time.Time
- func UnFreeze()
- type Carbon
- func Create(y int, mon time.Month, d, h, m, s, ns int, location string) (*Carbon, error)
- func CreateFromDate(y int, mon time.Month, d int, location string) (*Carbon, error)
- func CreateFromFormat(layout, value string, location string) (*Carbon, error)
- func CreateFromMonthAndYear(y int, mon time.Month, location string) (*Carbon, error)
- func CreateFromTime(h, m, s, ns int, location string) (*Carbon, error)
- func CreateFromTimestamp(timestamp int64, location string) (*Carbon, error)
- func CreateFromTimestampUTC(timestamp int64) (*Carbon, error)
- func MaxValue() *Carbon
- func MinValue() *Carbon
- func NewCarbon(t time.Time) *Carbon
- func Now() *Carbon
- func NowInLocation(loc string) (*Carbon, error)
- func Parse(layout, value, location string) (*Carbon, error)
- func Period(start *Carbon, days int, end *Carbon) ([]*Carbon, error)
- func Today(location string) (*Carbon, error)
- func Tomorrow(location string) (*Carbon, error)
- func Yesterday(location string) (*Carbon, error)
- func (c *Carbon) AddCenturies(cent int) *Carbon
- func (c *Carbon) AddCentury() *Carbon
- func (c *Carbon) AddDay() *Carbon
- func (c *Carbon) AddDays(d int) *Carbon
- func (c *Carbon) AddHour() *Carbon
- func (c *Carbon) AddHours(h int) *Carbon
- func (c *Carbon) AddMinute() *Carbon
- func (c *Carbon) AddMinutes(m int) *Carbon
- func (c *Carbon) AddMonth() *Carbon
- func (c *Carbon) AddMonthNoOverflow() *Carbon
- func (c *Carbon) AddMonths(m int) *Carbon
- func (c *Carbon) AddMonthsNoOverflow(m int) *Carbon
- func (c *Carbon) AddQuarter() *Carbon
- func (c *Carbon) AddQuarters(q int) *Carbon
- func (c *Carbon) AddSecond() *Carbon
- func (c *Carbon) AddSeconds(s int) *Carbon
- func (c *Carbon) AddWeek() *Carbon
- func (c *Carbon) AddWeekday() *Carbon
- func (c *Carbon) AddWeekdays(wd int) *Carbon
- func (c *Carbon) AddWeeks(w int) *Carbon
- func (c *Carbon) AddYear() *Carbon
- func (c *Carbon) AddYears(y int) *Carbon
- func (c *Carbon) Age() int
- func (c *Carbon) AtomString() string
- func (c *Carbon) Average(carb *Carbon) *Carbon
- func (c *Carbon) Between(a, b *Carbon, eq bool) bool
- func (c *Carbon) Closest(a, b *Carbon) *Carbon
- func (c *Carbon) CookieString() string
- func (c *Carbon) Copy() *Carbon
- func (c *Carbon) DateString() string
- func (c *Carbon) DateTimeString() string
- func (c *Carbon) DayDateTimeString() string
- func (c *Carbon) DaysInMonth() int
- func (c *Carbon) DaysInYear() int
- func (c *Carbon) DiffDurationInString(carb *Carbon) string
- func (c *Carbon) DiffFiltered(duration time.Duration, f Filter, carb *Carbon, abs bool) int64
- func (c *Carbon) DiffForHumans(d *Carbon, abs, absolute, short bool) (string, error)
- func (c *Carbon) DiffInDays(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInDaysFiltered(f Filter, carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInHours(d *Carbon, abs bool) int64
- func (c *Carbon) DiffInHoursFiltered(f Filter, carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInMinutes(d *Carbon, abs bool) int64
- func (c *Carbon) DiffInMonths(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInNights(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInSeconds(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInWeekdays(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInWeekendDays(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInWeeks(carb *Carbon, abs bool) int64
- func (c *Carbon) DiffInYears(carb *Carbon, abs bool) int64
- func (c *Carbon) EndOfCentury() *Carbon
- func (c *Carbon) EndOfDay() *Carbon
- func (c *Carbon) EndOfDecade() *Carbon
- func (c *Carbon) EndOfMonth() *Carbon
- func (c *Carbon) EndOfQuarter() *Carbon
- func (c *Carbon) EndOfWeek() *Carbon
- func (c *Carbon) EndOfYear() *Carbon
- func (c *Carbon) Eq(carb *Carbon) bool
- func (c *Carbon) EqualTo(carb *Carbon) bool
- func (c *Carbon) Farthest(a, b *Carbon) *Carbon
- func (c *Carbon) FirstDayOfMonth() *Carbon
- func (c *Carbon) FirstOfMonth(wd time.Weekday) *Carbon
- func (c *Carbon) FirstOfQuarter(wd time.Weekday) *Carbon
- func (c *Carbon) FirstOfYear(wd time.Weekday) *Carbon
- func (c *Carbon) FormattedDateString() string
- func (c *Carbon) GetLocale() string
- func (c *Carbon) GetTranslator() (*Translator, error)
- func (c *Carbon) GreaterThan(carb *Carbon) bool
- func (c *Carbon) GreaterThanOrEqualTo(carb *Carbon) bool
- func (c *Carbon) Gt(carb *Carbon) bool
- func (c *Carbon) Gte(carb *Carbon) bool
- func (c *Carbon) ISO8601String() string
- func (c *Carbon) IsCurrentMonth() bool
- func (c *Carbon) IsCurrentYear() bool
- func (c *Carbon) IsFriday() bool
- func (c *Carbon) IsFuture() bool
- func (c *Carbon) IsLastMonth() bool
- func (c *Carbon) IsLastWeek() bool
- func (c *Carbon) IsLeapYear() bool
- func (c *Carbon) IsLongYear() bool
- func (c *Carbon) IsMonday() bool
- func (c *Carbon) IsPast() bool
- func (c *Carbon) IsSameAs(format string, carb *Carbon) bool
- func (c *Carbon) IsSameDay(carb *Carbon) bool
- func (c *Carbon) IsSameMonth(carb *Carbon, sameYear bool) bool
- func (c *Carbon) IsSameYear(carb *Carbon) bool
- func (c *Carbon) IsSaturday() bool
- func (c *Carbon) IsSunday() bool
- func (c *Carbon) IsThursday() bool
- func (c *Carbon) IsToday() bool
- func (c *Carbon) IsTomorrow() bool
- func (c *Carbon) IsTuesday() bool
- func (c *Carbon) IsWednesday() bool
- func (c *Carbon) IsWeekday() bool
- func (c *Carbon) IsWeekend() bool
- func (c *Carbon) IsYesterday() bool
- func (c *Carbon) LastDayOfMonth() *Carbon
- func (c *Carbon) LastOfMonth(wd time.Weekday) *Carbon
- func (c *Carbon) LastOfQuarter(wd time.Weekday) *Carbon
- func (c *Carbon) LastOfYear(wd time.Weekday) *Carbon
- func (c *Carbon) LessThan(carb *Carbon) bool
- func (c *Carbon) LessThanOrEqualTo(carb *Carbon) bool
- func (c *Carbon) Lt(carb *Carbon) bool
- func (c *Carbon) Lte(carb *Carbon) bool
- func (c *Carbon) Max(carb *Carbon) *Carbon
- func (c *Carbon) Maximum(carb *Carbon) *Carbon
- func (c *Carbon) Min(carb *Carbon) *Carbon
- func (c *Carbon) Minimum(carb *Carbon) *Carbon
- func (c *Carbon) Ne(carb *Carbon) bool
- func (c *Carbon) Next(wd time.Weekday) *Carbon
- func (c *Carbon) NextWeekday() *Carbon
- func (c *Carbon) NextWeekendDay() *Carbon
- func (c *Carbon) NotEqualTo(carb *Carbon) bool
- func (c *Carbon) NthOfMonth(nth int, wd time.Weekday) *Carbon
- func (c *Carbon) NthOfQuarter(nth int, wd time.Weekday) *Carbon
- func (c *Carbon) NthOfYear(nth int, wd time.Weekday) *Carbon
- func (c *Carbon) Previous(wd time.Weekday) *Carbon
- func (c *Carbon) PreviousMonthLastDay() *Carbon
- func (c *Carbon) PreviousWeekday() *Carbon
- func (c *Carbon) PreviousWeekendDay() *Carbon
- func (c *Carbon) Quarter() int
- func (c *Carbon) RFC1036String() string
- func (c *Carbon) RFC1123String() string
- func (c *Carbon) RFC2822String() string
- func (c *Carbon) RFC3339String() string
- func (c *Carbon) RFC822String() string
- func (c *Carbon) RFC850String() string
- func (c *Carbon) RSSString() string
- func (c *Carbon) ResetStringFormat()
- func (c *Carbon) SecondsSinceMidnight() int
- func (c *Carbon) SecondsUntilEndOfDay() int
- func (c *Carbon) SetDate(y int, m time.Month, d int)
- func (c *Carbon) SetDateTime(y int, mon time.Month, d, h, m, s int)
- func (c *Carbon) SetDay(d int)
- func (c *Carbon) SetHour(h int)
- func (c *Carbon) SetLocale(l string) error
- func (c *Carbon) SetMinute(m int)
- func (c *Carbon) SetMonth(m time.Month)
- func (c *Carbon) SetSecond(s int)
- func (c *Carbon) SetStringFormat(format string)
- func (c *Carbon) SetTimeFromTimeString(timeString string) error
- func (c *Carbon) SetTimeZone(name string) error
- func (c *Carbon) SetTimestamp(sec int64)
- func (c *Carbon) SetTranslator(t *Translator)
- func (c *Carbon) SetWeekEndsAt(wd time.Weekday)
- func (c *Carbon) SetWeekStartsAt(wd time.Weekday)
- func (c *Carbon) SetWeekendDays(wds []time.Weekday)
- func (c *Carbon) SetYear(y int)
- func (c *Carbon) StartOfCentury() *Carbon
- func (c *Carbon) StartOfDay() *Carbon
- func (c *Carbon) StartOfDecade() *Carbon
- func (c *Carbon) StartOfMonth() *Carbon
- func (c *Carbon) StartOfQuarter() *Carbon
- func (c *Carbon) StartOfWeek() *Carbon
- func (c *Carbon) StartOfYear() *Carbon
- func (c *Carbon) String() string
- func (c *Carbon) SubCenturies(cent int) *Carbon
- func (c *Carbon) SubCentury() *Carbon
- func (c *Carbon) SubDay() *Carbon
- func (c *Carbon) SubDays(d int) *Carbon
- func (c *Carbon) SubHour() *Carbon
- func (c *Carbon) SubHours(h int) *Carbon
- func (c *Carbon) SubMinute() *Carbon
- func (c *Carbon) SubMinutes(m int) *Carbon
- func (c *Carbon) SubMonth() *Carbon
- func (c *Carbon) SubMonthNoOverflow() *Carbon
- func (c *Carbon) SubMonths(m int) *Carbon
- func (c *Carbon) SubMonthsNoOverflow(m int) *Carbon
- func (c *Carbon) SubQuarter() *Carbon
- func (c *Carbon) SubQuarters(q int) *Carbon
- func (c *Carbon) SubSecond() *Carbon
- func (c *Carbon) SubSeconds(s int) *Carbon
- func (c *Carbon) SubWeek() *Carbon
- func (c *Carbon) SubWeekday() *Carbon
- func (c *Carbon) SubWeekdays(wd int) *Carbon
- func (c *Carbon) SubWeeks(w int) *Carbon
- func (c *Carbon) SubYear() *Carbon
- func (c *Carbon) SubYears(y int) *Carbon
- func (c *Carbon) TimeString() string
- func (c *Carbon) TimeZone() string
- func (c *Carbon) Timestamp() int64
- func (c *Carbon) W3CString() string
- func (c *Carbon) WeekEndsAt() time.Weekday
- func (c *Carbon) WeekOfMonth() int
- func (c *Carbon) WeekOfYear() (int, int)
- func (c *Carbon) WeekStartsAt() time.Weekday
- func (c *Carbon) WeekendDays() []time.Weekday
- type CarbonInterval
- type Filter
- type Translator
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, Jan 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 ¶
var ( ErrEndMustBeAfterStart = errors.New("end date must be after start date") ErrDayAtLeast1 = errors.New("days must be at least 1") )
Functions ¶
func After ¶
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 Sleep ¶
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
Types ¶
type Carbon ¶
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 ¶
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 ¶
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 ¶
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 ¶ added in v0.1.3
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 ¶
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 ¶
CreateFromTimestamp returns a new pointer to a Carbon instance from a timestamp. If the location is invalid, it returns an error instead.
func CreateFromTimestampUTC ¶
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 ¶
func MaxValue() *Carbon
MaxValue returns a pointer to a new carbon instance for greatest supported date
func MinValue ¶
func MinValue() *Carbon
MinValue returns a pointer to a new carbon instance for lowest supported date
func NowInLocation ¶
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 ¶
Parse returns a pointer to a new carbon instance from a string If the location is invalid, it returns an error instead.
func Period ¶ added in v0.2.2
Period returns an array of Carbon dates by accepting start date, number of days, and end date. Useful for generating a recurring dates.
func Today ¶
Today returns a pointer to a new carbon instance for today If the location is invalid, it returns an error instead.
func Tomorrow ¶
Tomorrow returns a pointer to a new carbon instance for tomorrow If the location is invalid, it returns an error instead.
func Yesterday ¶
Yesterday returns a pointer to a new carbon instance for yesterday If the location is invalid, it returns an error instead.
func (*Carbon) AddCenturies ¶
AddCenturies adds centuries to the time. Positive values travels forward while negative values travels into the past
func (*Carbon) AddCentury ¶
AddCentury adds a century to the current time
func (*Carbon) AddDays ¶
AddDays adds a day to the current time. Positive value travels forward while negative value travels into the past
func (*Carbon) AddHours ¶
AddHours adds an hour to the current time. Positive value travels forward while negative value travels into the past
func (*Carbon) AddMinutes ¶
AddMinutes adds minutes to the current time. Positive value travels forward while negative value travels into the past.
func (*Carbon) AddMonthNoOverflow ¶
AddMonthNoOverflow adds a month with no overflow to the current time
func (*Carbon) AddMonths ¶
AddMonths adds months to the current time. Positive value travels forward while negative values travels into the past
func (*Carbon) AddMonthsNoOverflow ¶
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 ¶
AddQuarter adds a quarter to the current time
func (*Carbon) AddQuarters ¶
AddQuarters adds quarters to the current time. Positive values travel forward while negative values travel into the past
func (*Carbon) AddSeconds ¶
AddSeconds adds seconds to the current time. Positive values travels forward while negative values travels into the past.
func (*Carbon) AddWeekday ¶
AddWeekday adds a weekday to the current time
func (*Carbon) AddWeekdays ¶
AddWeekdays adds a weekday to the current time. Positive value travels forward while negative value travels into the past
func (*Carbon) AddWeeks ¶
AddWeeks adds a week to the current time. Positive value travels forward while negative value travels into the past.
func (*Carbon) AddYears ¶
AddYears adds a year to the current time. Positive values travel forward while negative values travel into the past
func (*Carbon) AtomString ¶
AtomString formats the current time to a Atom date format
func (*Carbon) Average ¶
Average returns the average between a given carbon date and the current date
func (*Carbon) Between ¶
Between determines if the current instance is between two others eq Indicates if a > and < comparison should be used or <= or >=
func (*Carbon) CookieString ¶
CookieString formats the current time to a Cookie date format
func (*Carbon) DateString ¶
DateString return the current time in Y-m-d format
func (*Carbon) DateTimeString ¶
DateTimeString returns the current time in Y-m-d hh:mm:ss format
func (*Carbon) DayDateTimeString ¶
DayDateTimeString returns the current time with a day, date and time format
func (*Carbon) DaysInMonth ¶
DaysInMonth returns the number of days in the month
func (*Carbon) DaysInYear ¶
DaysInYear returns the number of days in the year
func (*Carbon) DiffDurationInString ¶
DiffDurationInString returns the duration difference in string format
func (*Carbon) DiffFiltered ¶
DiffFiltered returns the difference by the given duration using a filter
func (*Carbon) DiffForHumans ¶
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 ¶
DiffInDays returns the difference in days
func (*Carbon) DiffInDaysFiltered ¶
DiffInDaysFiltered returns the difference in days using a filter
func (*Carbon) DiffInHours ¶
DiffInHours returns the difference in hours
func (*Carbon) DiffInHoursFiltered ¶
DiffInHoursFiltered returns the difference in hours using a filter
func (*Carbon) DiffInMinutes ¶
DiffInMinutes returns the difference in minutes
func (*Carbon) DiffInMonths ¶
DiffInMonths returns the difference in months
func (*Carbon) DiffInNights ¶
DiffInNights returns the difference in nights
func (*Carbon) DiffInSeconds ¶
DiffInSeconds returns the difference in seconds
func (*Carbon) DiffInWeekdays ¶
DiffInWeekdays returns the difference in weekdays
func (*Carbon) DiffInWeekendDays ¶
DiffInWeekendDays returns the difference in weekend days using a filter
func (*Carbon) DiffInWeeks ¶
DiffInWeeks returns the difference in weeks
func (*Carbon) DiffInYears ¶
DiffInYears returns the difference in years
func (*Carbon) EndOfCentury ¶
EndOfCentury returns the date of the end of the century at 23:59:59
func (*Carbon) EndOfDecade ¶
EndOfDecade returns the date at the end of the decade and time at 23:59:59
func (*Carbon) EndOfMonth ¶
EndOfMonth returns the date at the end of the month and time at 23:59:59
func (*Carbon) EndOfQuarter ¶
EndOfQuarter returns the date at end of the quarter and time at 23:59:59
func (*Carbon) FirstDayOfMonth ¶
FirstDayOfMonth returns a new carbon instance with the first day of current month
func (*Carbon) FirstOfMonth ¶
FirstOfMonth returns the first occurrence of a given day of the week in the current month
func (*Carbon) FirstOfQuarter ¶
FirstOfQuarter returns the first occurrence of a given day of the week in the current quarter
func (*Carbon) FirstOfYear ¶
FirstOfYear returns the first occurrence of a given day of the week in the current year
func (*Carbon) FormattedDateString ¶
FormattedDateString returns the current time as a readable date
func (*Carbon) GetTranslator ¶
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 ¶
GreaterThan determines if the current carbon is greater (after) than another
func (*Carbon) GreaterThanOrEqualTo ¶
GreaterThanOrEqualTo determines if the instance is greater (after) than or equal to another
func (*Carbon) ISO8601String ¶
ISO8601String returns the current time in ISO8601 format
func (*Carbon) IsCurrentMonth ¶
IsCurrentMonth determines if the current time is in the current month
func (*Carbon) IsCurrentYear ¶
IsCurrentYear determines if the current time is in the current year
func (*Carbon) IsFuture ¶
IsFuture determines if the current time is in the future, ie. greater (after) than now
func (*Carbon) IsLastMonth ¶
IsLastMonth returns true is the date is within last month
func (*Carbon) IsLastWeek ¶
IsLastWeek returns true is the date is within last week
func (*Carbon) IsLeapYear ¶
IsLeapYear determines if current current time is a leap year
func (*Carbon) IsLongYear ¶
IsLongYear determines if the instance is a long year
func (*Carbon) IsPast ¶
IsPast determines if the current time is in the past, ie. less (before) than now
func (*Carbon) IsSameAs ¶
IsSameAs compares the formatted values of the two dates. If passed date is nil, compares against today
func (*Carbon) IsSameDay ¶
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 ¶
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 ¶
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 ¶
IsSaturday checks if this day is a Saturday.
func (*Carbon) IsThursday ¶
IsThursday checks if this day is a Thursday.
func (*Carbon) IsTomorrow ¶
IsTomorrow determines if the current time is tomorrow
func (*Carbon) IsWednesday ¶
IsWednesday checks if this day is a Wednesday.
func (*Carbon) IsYesterday ¶
IsYesterday determines if the current time is yesterday
func (*Carbon) LastDayOfMonth ¶
LastDayOfMonth returns a new carbon instance with the last day of current month
func (*Carbon) LastOfMonth ¶
LastOfMonth returns the last occurrence of a given day of the week in the current month
func (*Carbon) LastOfQuarter ¶
LastOfQuarter returns the last occurrence of a given day of the week in the current quarter
func (*Carbon) LastOfYear ¶
LastOfYear returns the last occurrence of a given day of the week in the current year
func (*Carbon) LessThanOrEqualTo ¶
LessThanOrEqualTo determines if the instance is less (before) or equal to another
func (*Carbon) Max ¶
Max returns the maximum instance between a given instance and the current instance
func (*Carbon) Maximum ¶
Maximum returns the maximum instance between a given instance and the current instance
func (*Carbon) Min ¶
Min returns the minimum instance between a given instance and the current instance
func (*Carbon) Minimum ¶
Minimum returns the minimum instance between a given instance and the current instance
func (*Carbon) NextWeekday ¶
NextWeekday goes forward to the next weekday
func (*Carbon) NextWeekendDay ¶
NextWeekendDay goes forward to the next weekend day
func (*Carbon) NotEqualTo ¶
NotEqualTo determines if the current carbon is not equal to another
func (*Carbon) NthOfMonth ¶
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 ¶
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 ¶
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 ¶
Previous changes the time to the previous occurrence of a given day of the week
func (*Carbon) PreviousMonthLastDay ¶
PreviousMonthLastDay returns the last day of the previous month
func (*Carbon) PreviousWeekday ¶
PreviousWeekday goes back to the previous weekday
func (*Carbon) PreviousWeekendDay ¶
PreviousWeekendDay goes back to the previous weekend day
func (*Carbon) RFC1036String ¶
RFC1036String returns the current time in RFC 1036 format
func (*Carbon) RFC1123String ¶
RFC1123String returns the current time in RFC 1123 format
func (*Carbon) RFC2822String ¶
RFC2822String returns the current time in RFC 2822 format
func (*Carbon) RFC3339String ¶
RFC3339String returns the current time in RFC 3339 format
func (*Carbon) RFC822String ¶
RFC822String returns the current time in RFC 822 format
func (*Carbon) RFC850String ¶
RFC850String returns the current time in RFC 850 format
func (*Carbon) ResetStringFormat ¶
func (c *Carbon) ResetStringFormat()
ResetStringFormat changes the format to the DefaultFormat
func (*Carbon) SecondsSinceMidnight ¶
SecondsSinceMidnight returns the number of seconds since midnight.
func (*Carbon) SecondsUntilEndOfDay ¶
SecondsUntilEndOfDay returns the number of seconds until 23:59:59.
func (*Carbon) SetDateTime ¶
SetDateTime sets the date and the time
func (*Carbon) SetStringFormat ¶
SetStringFormat formats the current time with the set format string
func (*Carbon) SetTimeFromTimeString ¶
SetTimeFromTimeString receives a string and sets the current time It accepts the following formats: "hh:mm:ss", "hh:mm" and "hh"
func (*Carbon) SetTimeZone ¶
SetTimeZone sets the location from a string If the location is invalid, it returns an error instead.
func (*Carbon) SetTimestamp ¶
SetTimestamp sets the current time given a timestamp
func (*Carbon) SetTranslator ¶
func (c *Carbon) SetTranslator(t *Translator)
SetTranslator sets the Translator inside a Carbon instance
func (*Carbon) SetWeekEndsAt ¶
SetWeekEndsAt sets the last day of week
func (*Carbon) SetWeekStartsAt ¶
SetWeekStartsAt sets the first day of week
func (*Carbon) SetWeekendDays ¶
SetWeekendDays sets the weekend days
func (*Carbon) StartOfCentury ¶
StartOfCentury returns the date of the first day of the century at 00:00:00
func (*Carbon) StartOfDay ¶
StartOfDay returns the time at 00:00:00 of the same day
func (*Carbon) StartOfDecade ¶
StartOfDecade returns the date at the first day of the decade and time at 00:00:00
func (*Carbon) StartOfMonth ¶
StartOfMonth returns the date on the first day of the month and the time to 00:00:00
func (*Carbon) StartOfQuarter ¶
StartOfQuarter returns the date at the first day of the quarter and time at 00:00:00
func (*Carbon) StartOfWeek ¶
StartOfWeek returns the date of the first day of week at 00:00:00
func (*Carbon) StartOfYear ¶
StartOfYear returns the date at the first day of the year and the time at 00:00:00
func (*Carbon) SubCenturies ¶
SubCenturies removes centuries from the current time
func (*Carbon) SubCentury ¶
SubCentury removes a century from the current time
func (*Carbon) SubMinutes ¶
SubMinutes removes minutes from the current time
func (*Carbon) SubMonthNoOverflow ¶
SubMonthNoOverflow remove a month with no overflow from the current time
func (*Carbon) SubMonthsNoOverflow ¶
SubMonthsNoOverflow removes months with no overflow from the current time
func (*Carbon) SubQuarter ¶
SubQuarter removes a quarter from the current time
func (*Carbon) SubQuarters ¶
SubQuarters removes quarters from current time
func (*Carbon) SubSeconds ¶
SubSeconds removes seconds from the current time
func (*Carbon) SubWeekday ¶
SubWeekday removes a weekday from the current time
func (*Carbon) SubWeekdays ¶
SubWeekdays removes a weekday from the current time
func (*Carbon) TimeString ¶
TimeString returns the current time in hh:mm:ss format
func (*Carbon) WeekEndsAt ¶
WeekEndsAt gets the ending day of the week
func (*Carbon) WeekOfMonth ¶
WeekOfMonth returns the week of the month
func (*Carbon) WeekOfYear ¶
WeekOfYear returns the week of the current year. This is an alias for time.ISOWeek
func (*Carbon) WeekStartsAt ¶
WeekStartsAt get the starting day of the week
func (*Carbon) WeekendDays ¶
WeekendDays gets the weekend days of the week
type CarbonInterval ¶
CarbonInterval represents an interval between two carbons.
func NewCarbonInterval ¶
func NewCarbonInterval(start, end *Carbon) (*CarbonInterval, error)
NewCarbonInterval returns a pointer to a new CarbonInterval instance
func (*CarbonInterval) DiffInHours ¶
func (ci *CarbonInterval) DiffInHours() int64
DiffInHours return the difference in hours between start and end date
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator helps to translate time based on locale
func NewTranslator ¶
func NewTranslator() *Translator
NewTranslator returns a initialized instance of Translator
func (*Translator) AssertValidLocale ¶
func (t *Translator) AssertValidLocale(l string) error
AssertValidLocale checks if the locale is valid or not
func (*Translator) GetLocale ¶
func (t *Translator) GetLocale() string
GetLocale will return locale of a Translator
func (*Translator) SetLocale ¶
func (t *Translator) SetLocale(l string) error
SetLocale will set locale on a Translator