helpers

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCookieAuth

func ExtractCookieAuth(r *http.Request, config *config.Config) (username *string, err error)

func FmtWakatimeDuration

func FmtWakatimeDuration(d time.Duration) string

func FormatDate

func FormatDate(date time.Time) string

func FormatDateHuman

func FormatDateHuman(date time.Time) string

func FormatDateTime

func FormatDateTime(date time.Time) string

func FormatDateTimeHuman

func FormatDateTimeHuman(date time.Time) string

func MustParseInterval

func MustParseInterval(interval string) *models.IntervalKey

func MustResolveIntervalRawTZ

func MustResolveIntervalRawTZ(interval string, tz *time.Location) (from, to time.Time)

func ParseDateTimeTZ

func ParseDateTimeTZ(date string, tz *time.Location) (time.Time, error)

ParseDateTimeTZ attempts to parse the given date string from multiple formats. First, a time-zoned date-time string (e.g. 2006-01-02T15:04:05+02:00) is tried Second, a non-time-zoned date-time string (e.g. 2006-01-02 15:04:05) is tried at the given zone Third, a non-time-zoned date string (e.g. 2006-01-02) is tried at the given zone Example: - Server runs in CEST (UTC+2), requesting user lives in PDT (UTC-7). - 2021-04-25T10:30:00Z, 2021-04-25T3:30:00-0100 and 2021-04-25T12:30:00+0200 are equivalent, they represent the same point in time - When user requests non-time-zoned range (e.g. 2021-04-25T00:00:00), but has their time zone properly configured, this will resolve to 2021-04-25T09:00:00

func ParseInterval

func ParseInterval(interval string) (*models.IntervalKey, error)

func ParseSummaryFilters

func ParseSummaryFilters(r *http.Request) *models.Filters

func ParseSummaryParams

func ParseSummaryParams(r *http.Request) (*models.SummaryParams, error)

func ResolveIntervalRawTZ

func ResolveIntervalRawTZ(interval string, tz *time.Location) (err error, from, to time.Time)

func ResolveIntervalTZ

func ResolveIntervalTZ(interval *models.IntervalKey, tz *time.Location) (err error, from, to time.Time)

func ResolveMaximumRange

func ResolveMaximumRange(days int) (error, *models.IntervalKey)

ResolveMaximumRange returns the interval label (e.g. "last_7_days") of the maximum allowed range when having opted to share this many days or an error for days == 0.

func RespondJSON

func RespondJSON(w http.ResponseWriter, r *http.Request, status int, object interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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