tenanttime

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

Clock resolves one business timezone from a setting and converts between the calendar days and clock times people type or read (in that zone) and the UTC instants stored in the database. The setting is read through the source function, so a changed setting is picked up within a few seconds. An empty setting means UTC. A setting that names an unknown zone also falls back to UTC, and onError (when given) is told once per bad name.

func New

func New(source func() string, onError func(format string, args ...interface{})) *Clock

func (*Clock) DateString

func (c *Clock) DateString(t time.Time) string

DateString is the calendar day (YYYY-MM-DD) of an instant in the business timezone.

func (*Clock) DayEndExclusiveUTC

func (c *Clock) DayEndExclusiveUTC(date string) (time.Time, error)

DayEndExclusiveUTC is the instant the day after "date" begins. Compare with "< DayEndExclusiveUTC(to)" so the whole last day is included.

func (*Clock) DayStartOf

func (c *Clock) DayStartOf(t time.Time) time.Time

DayStartOf is the instant the business-timezone day containing t began.

func (*Clock) DayStartUTC

func (c *Clock) DayStartUTC(date string) (time.Time, error)

DayStartUTC is the instant the business-timezone calendar day "YYYY-MM-DD" begins. Compare timestamps with ">= DayStartUTC(from)".

func (*Clock) Local

func (c *Clock) Local(t time.Time) time.Time

Local expresses an instant in the business timezone, for display.

func (*Clock) Location

func (c *Clock) Location() *time.Location

func (*Clock) MonthStartOf

func (c *Clock) MonthStartOf(t time.Time) time.Time

MonthStartOf is the instant the business-timezone month containing t began.

func (*Clock) Name

func (c *Clock) Name() string

Name is the IANA name of Location, as a browser Intl API accepts it.

func (*Clock) Now

func (c *Clock) Now() time.Time

func (*Clock) ParseLocal

func (c *Clock) ParseLocal(date, clock string) (time.Time, error)

ParseLocal turns a date ("2006-01-02") and a clock time ("15:04", seconds optional) typed in the business timezone into a UTC instant.

func (*Clock) TodayStartUTC

func (c *Clock) TodayStartUTC() time.Time

TodayStartUTC is the instant today began in the business timezone.

Jump to

Keyboard shortcuts

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