timeutil

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeUtil

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

TimeUtil wraps a Carbon instance for chainable time utility operations.

func FromTime

func FromTime(t time.Time) *TimeUtil

FromTime creates a TimeUtil from a standard time.Time value.

func New

func New() *TimeUtil

New returns a new TimeUtil initialized to the current time.

func Parse

func Parse(dateStr string) (*TimeUtil, error)

Parse parses a date string into a TimeUtil instance. Returns an error if the string is not a valid date.

func (*TimeUtil) AddDays

func (t *TimeUtil) AddDays(days int) *TimeUtil

AddDays adds the specified number of days and returns the updated TimeUtil.

func (*TimeUtil) Carbon

func (t *TimeUtil) Carbon() *carbon.Carbon

Carbon returns the underlying Carbon pointer instance.

func (*TimeUtil) DifferenceInDays

func (t *TimeUtil) DifferenceInDays(other *TimeUtil) int64

DifferenceInDays returns the number of days between this and another TimeUtil.

func (*TimeUtil) EndOfWeek

func (t *TimeUtil) EndOfWeek() *TimeUtil

EndOfWeek returns a new TimeUtil set to the end of the week.

func (*TimeUtil) Format

func (t *TimeUtil) Format(layout string) string

Format formats the internal time using the given layout string.

func (*TimeUtil) IsWeekend

func (t *TimeUtil) IsWeekend() bool

IsWeekend returns true if the current time is a weekend.

func (*TimeUtil) StartOfWeek

func (t *TimeUtil) StartOfWeek() *TimeUtil

StartOfWeek returns a new TimeUtil set to the beginning of the week.

func (*TimeUtil) SubtractDays

func (t *TimeUtil) SubtractDays(days int) *TimeUtil

SubtractDays subtracts the specified number of days and returns the updated TimeUtil.

func (*TimeUtil) ToTime

func (t *TimeUtil) ToTime() time.Time

ToTime returns the standard time.Time representation of the internal Carbon time.

Jump to

Keyboard shortcuts

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