Documentation
¶
Overview ¶
Package common contains common routines for the stlview pages. Dates, represented by time.Time, are always in the UTC timezone.
Index ¶
Constants ¶
const ( Date = "date" DayPage = "/day" SummaryPage = "/summary" DateRangePage = "/daterange" )
Variables ¶
This section is empty.
Functions ¶
func NewTemplate ¶
NewTemplate returns a new template instance. name is the name of the template; templateStr is the template string.
Types ¶
type DateHandler ¶
type DateHandler interface {
// DrillDown returns the link for a date in the summary table.
DrillDown(date time.Time) *url.URL
// DrillDownFormat returns the date in the summary table properly formatted
DrillDownFormat(date time.Time) string
// DrillUp returns the link to the page one level up.
DrillUp(current time.Time) *url.URL
// Format formats the current date for the page
Format(current time.Time) string
// Prev returns a link to the previous page.
Prev(current time.Time) *url.URL
// Next returns a link to the next page.
Next(current time.Time) *url.URL
// Recurring says whether the summary table should be daily or monthly.
Recurring() aggregators.Recurring
// End returns the end date for the current page.
End(current time.Time) time.Time
// Normalize normalizes the current date
Normalize(current time.Time) time.Time
}
DateHandler handles dates.
func Day ¶
func Day() DateHandler
func Month ¶
func Month() DateHandler
func ParseDateParam ¶
func ParseDateParam( dateParam string, now int64, loc *time.Location, defaultHandler DateHandler) (time.Time, DateHandler)
ParseDateParam parses the value of the date parameter. If the date parameter is of the form yyyy, then ParseDateParam returns the year with the year DateHandler. If the date parameter is of the form yyyyMM, then ParseDateParam returns the year and month with the month DateHandler. If the date parameter is of the form yyyyMMdd, then ParseDateParam returns the year, month, and day with the day DateHandler. If there is an error parsing the date, ParseDateParam returns the current date according to the now and loc parameter normalized with the defaultHandler along with the defaultHandler.
func Year ¶
func Year() DateHandler
type PercentFormatter ¶
type PercentFormatter struct {
}
PercentFormat formats percents.
func (*PercentFormatter) FormatPercent ¶
func (p *PercentFormatter) FormatPercent(percent float64) string
FormatPercent formats a percent.
type SpeedFormatter ¶
type SpeedFormatter struct {
}
SpeedFormatter formats internet speeds.
func (*SpeedFormatter) FormatSpeed ¶
func (s *SpeedFormatter) FormatSpeed(mbps float64) string
FormatSpeed formats an internet speed.
type TimestampFormatter ¶
TimestampFormatter handles formatting timestamps
func (*TimestampFormatter) FormatTimestamp ¶
func (t *TimestampFormatter) FormatTimestamp(ts int64) string
FormatTimestamp formats a timestamp.