Documentation
¶
Index ¶
- type Clock
- func (c *Clock) DateString(t time.Time) string
- func (c *Clock) DayEndExclusiveUTC(date string) (time.Time, error)
- func (c *Clock) DayStartOf(t time.Time) time.Time
- func (c *Clock) DayStartUTC(date string) (time.Time, error)
- func (c *Clock) Local(t time.Time) time.Time
- func (c *Clock) Location() *time.Location
- func (c *Clock) MonthStartOf(t time.Time) time.Time
- func (c *Clock) Name() string
- func (c *Clock) Now() time.Time
- func (c *Clock) ParseLocal(date, clock string) (time.Time, error)
- func (c *Clock) TodayStartUTC() time.Time
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 (*Clock) DateString ¶
DateString is the calendar day (YYYY-MM-DD) of an instant in the business timezone.
func (*Clock) DayEndExclusiveUTC ¶
DayEndExclusiveUTC is the instant the day after "date" begins. Compare with "< DayEndExclusiveUTC(to)" so the whole last day is included.
func (*Clock) DayStartOf ¶
DayStartOf is the instant the business-timezone day containing t began.
func (*Clock) DayStartUTC ¶
DayStartUTC is the instant the business-timezone calendar day "YYYY-MM-DD" begins. Compare timestamps with ">= DayStartUTC(from)".
func (*Clock) MonthStartOf ¶
MonthStartOf is the instant the business-timezone month containing t began.
func (*Clock) ParseLocal ¶
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 ¶
TodayStartUTC is the instant today began in the business timezone.