Go CLI that turns the markdown currency of this stack (Redmine notes, Discourse posts, briefing output) into typeset PDFs: two embedded typst templates (report with title page/TOC/headers, dense brief), front-matter (title/subtitle/author/date/classification/template), GFM tables, and bar charts rendered in pure Go (go-chart) from fenced chart data blocks. Engine is a prebuilt typst 0.15.1 container pinned by digest and run --network none; PDF bytes to stdout or -o. Exit codes 0/1/2. All dev in docker (dev.sh/Makefile); unit tests + golden typst fixtures plus a host-side smoke against the real engine container. Generated with Crush Assisted-by: Crush:glm-5.2
47 lines
918 B
Go
47 lines
918 B
Go
package chart
|
|
|
|
import (
|
|
"sort"
|
|
"time"
|
|
)
|
|
|
|
// Assert types implement interfaces.
|
|
var (
|
|
_ Sequence = (*Times)(nil)
|
|
_ sort.Interface = (*Times)(nil)
|
|
)
|
|
|
|
// Times are an array of times.
|
|
// It wraps the array with methods that implement `seq.Provider`.
|
|
type Times []time.Time
|
|
|
|
// Array returns the times to an array.
|
|
func (t Times) Array() []time.Time {
|
|
return []time.Time(t)
|
|
}
|
|
|
|
// Len returns the length of the array.
|
|
func (t Times) Len() int {
|
|
return len(t)
|
|
}
|
|
|
|
// GetValue returns a value at an index as a time.
|
|
func (t Times) GetValue(index int) float64 {
|
|
return ToFloat64(t[index])
|
|
}
|
|
|
|
// Swap implements sort.Interface.
|
|
func (t Times) Swap(i, j int) {
|
|
t[i], t[j] = t[j], t[i]
|
|
}
|
|
|
|
// Less implements sort.Interface.
|
|
func (t Times) Less(i, j int) bool {
|
|
return t[i].Before(t[j])
|
|
}
|
|
|
|
// ToFloat64 returns a float64 representation of a time.
|
|
func ToFloat64(t time.Time) float64 {
|
|
return float64(t.UnixNano())
|
|
}
|