date_utils

package
v1.260.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DurationFifteenMinutes = time.Minute * 15
View Source
const DurationOneDay = time.Hour * 24
View Source
const DurationOneWeek = DurationOneDay * 7
View Source
const TimeZoneString = "Africa/Johannesburg"

Variables

This section is empty.

Functions

func BeginningOfNextDay added in v1.233.0

func BeginningOfNextDay(date time.Time) time.Time

BeginningOfNextDay is useful for specifying intervals where the beginning of the next day is excluded e.g. date < beginningOfNextDay

func ConvertToNoDateTimeString

func ConvertToNoDateTimeString(timeString *string) (*string, error)

ConvertToNoDateTimeString - Converts a PSQL Time type to Go Time type

func CurrentDate

func CurrentDate() time.Time

func CurrentLocation

func CurrentLocation() *time.Location

func DateDBFormattedString

func DateDBFormattedString(date time.Time) string

func DateDBFormattedStringDateOnly

func DateDBFormattedStringDateOnly(date time.Time) string

func DateEqual

func DateEqual(date1, date2 time.Time) bool

func DateLayoutDB

func DateLayoutDB() string

func DateLayoutFilenameSafe

func DateLayoutFilenameSafe() string

func DateLayoutForDB

func DateLayoutForDB() string

func DateLayoutHumanReadable

func DateLayoutHumanReadable() string

func DateLayoutHumanReadableWithTime

func DateLayoutHumanReadableWithTime() string

func DateLayoutTime

func DateLayoutTime() string

func DateLayoutTrimmed

func DateLayoutTrimmed() string

func DateLayoutYearMonthDay

func DateLayoutYearMonthDay() string

func DateLayoutYearMonthDayTime

func DateLayoutYearMonthDayTime() string

func DateLayoutYearMonthDayTimeMillisecondTZ

func DateLayoutYearMonthDayTimeMillisecondTZ() string

func DateLayoutYearMonthDayTimeT

func DateLayoutYearMonthDayTimeT() string

func DateLayoutYearMonthDayTimeTZ

func DateLayoutYearMonthDayTimeTZ() string

func DateLayoutYearMonthDayTimeTimezone

func DateLayoutYearMonthDayTimeTimezone() string

func DateLocal

func DateLocal(date *time.Time)

func DatePtrToString added in v1.233.0

func DatePtrToString(date *time.Time) string

DatePtrToString converts a time.Time pointer to a string in the format "2006-01-02 15:04:05".

func DatePtrToTimeString added in v1.233.0

func DatePtrToTimeString(date *time.Time) string

DatePtrToTimeString converts a time.Time pointer to a string in the format "15:04". If the pointer is nil, it returns "--:--".

func EndOfDay added in v1.233.0

func EndOfDay(date time.Time) time.Time

func FormatTimestampsWithTimeZoneOnStructRecursively added in v1.150.0

func FormatTimestampsWithTimeZoneOnStructRecursively(object any, location *time.Location) error

func ParseTimeString

func ParseTimeString(timeString string) (time.Time, error)

ParseTimeString attempts to parse the string as the default date-time format, or as a date only format

func StartOfDay added in v1.233.0

func StartOfDay(date time.Time) time.Time

func TimeBefore

func TimeBefore(a string, b string) bool

TimeBefore determines whether a (string format HH:mm) is earlier than b (string format HH:mm)

func TodayEnd added in v1.233.0

func TodayEnd() string

func TodayStart added in v1.233.0

func TodayStart() string

Types

type TradingHours added in v1.206.0

type TradingHours struct {
	Monday    TradingHoursDay `json:"monday"`
	Tuesday   TradingHoursDay `json:"tuesday"`
	Wednesday TradingHoursDay `json:"wednesday"`
	Thursday  TradingHoursDay `json:"thursday"`
	Friday    TradingHoursDay `json:"friday"`
	Saturday  TradingHoursDay `json:"saturday"`
	Sunday    TradingHoursDay `json:"sunday"`
	Holidays  TradingHoursDay `json:"holidays"`
}

func (TradingHours) String added in v1.208.0

func (t TradingHours) String() string

func (TradingHours) Validate added in v1.208.0

func (t TradingHours) Validate() error

type TradingHoursDay added in v1.250.0

type TradingHoursDay struct {
	StartTime string `json:"start_time"`
	EndTime   string `json:"end_time"`
}

func (TradingHoursDay) String added in v1.250.0

func (day TradingHoursDay) String() string

func (TradingHoursDay) Validate added in v1.250.0

func (day TradingHoursDay) Validate() error

Jump to

Keyboard shortcuts

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