types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package types provides shared types used across the Basecamp SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	Year  int        // Year (e.g., 2024)
	Month time.Month // Month of the year (January = 1, ...)
	Day   int        // Day of the month, starting at 1
}

Date represents a calendar date (year, month, day) without time or timezone. Use this for date-only fields like due_on and starts_on.

func DateOf

func DateOf(t time.Time) Date

DateOf returns the Date portion of a time.Time in that time's location.

func ParseDate

func ParseDate(s string) (Date, error)

ParseDate parses a string in YYYY-MM-DD format.

func Today

func Today() Date

Today returns today's date in the local timezone.

func (Date) AddDays

func (d Date) AddDays(n int) Date

AddDays returns the date n days from d.

func (Date) AddMonths

func (d Date) AddMonths(n int) Date

AddMonths returns the date n months from d.

func (Date) AddYears

func (d Date) AddYears(n int) Date

AddYears returns the date n years from d.

func (Date) After

func (d Date) After(other Date) bool

After reports whether d is after other.

func (Date) Before

func (d Date) Before(other Date) bool

Before reports whether d is before other.

func (Date) Compare

func (d Date) Compare(other Date) int

Compare compares d and other. Returns -1 if d < other, 0 if equal, +1 if d > other.

func (Date) DaysSince

func (d Date) DaysSince(s Date) int

DaysSince returns the number of days from s to d (d - s).

func (Date) Equal

func (d Date) Equal(other Date) bool

Equal reports whether d and other represent the same date.

func (Date) GoString

func (d Date) GoString() string

GoString returns a Go-syntax representation for debugging.

func (Date) In

func (d Date) In(loc *time.Location) time.Time

In returns the time.Time corresponding to midnight of the date in the given location.

func (Date) IsValid

func (d Date) IsValid() bool

IsValid reports whether the date represents a valid calendar date.

func (Date) IsZero

func (d Date) IsZero() bool

IsZero reports whether the date is the zero value.

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. Zero dates marshal as null, valid dates as "YYYY-MM-DD".

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Date) String

func (d Date) String() string

String returns the date in YYYY-MM-DD format.

func (Date) UTC

func (d Date) UTC() time.Time

UTC returns the time.Time corresponding to midnight UTC of the date.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. Accepts "YYYY-MM-DD" strings and null.

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (Date) Weekday

func (d Date) Weekday() time.Weekday

Weekday returns the day of the week.

Jump to

Keyboard shortcuts

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