summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-03-14 18:18:31 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-03-17 13:49:41 -0400
commitb54a1c9686eec3c1114e9b58cb67679ba59c45bd (patch)
tree0bdb2f3ed51ff077a8c3e337e4bc556aacec108e /util
parent54feeb027d6e5a760b49769dfe695ea2591dc6fe (diff)
directories
Diffstat (limited to 'util')
-rw-r--r--util/date.go51
-rw-r--r--util/html.go14
2 files changed, 0 insertions, 65 deletions
diff --git a/util/date.go b/util/date.go
deleted file mode 100644
index 3b5c457..0000000
--- a/util/date.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package util
-
-import (
- "html/template"
- "time"
-)
-
-func Date2HTML(t time.Time) template.HTML {
- return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\" title=\"2006-01-02 15:04:05\">2006-01-02 <span class=time>15:04:05</span></time>"))
-}
-
-func DateTime2HTML(t time.Time) template.HTML {
- return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
-}
-
-func DateTime2ColorHTML(t time.Time) template.HTML {
- return template.HTML(t.Local().Format("<time class=daily datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>"))
-}
-
-type TimeRange struct {
- A, B time.Time
-}
-
-func (tr TimeRange) ToPct(point time.Time) float64 {
- dur_ab := tr.B.Sub(tr.A)
- dur_ap := point.Sub(tr.A)
- return float64(dur_ap) / float64(dur_ab)
-}
-
-type ByteRange struct {
- A, B byte
-}
-
-func (br ByteRange) FromPct(pct float64) byte {
- ab := int16(br.B) - int16(br.A)
- ap := int16(pct * float64(ab))
- return byte(int16(br.A) + ap)
-}
-
-func PctCap(pct float64) float64 {
- if pct < 0 {
- pct = 0
- } else if pct > 1 {
- pct = 1
- }
- return pct
-}
-
-func MapRange(tr TimeRange, br ByteRange, t time.Time) byte {
- return br.FromPct(PctCap(tr.ToPct(t)))
-}
diff --git a/util/html.go b/util/html.go
deleted file mode 100644
index af2ce60..0000000
--- a/util/html.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package util
-
-import (
- "html/template"
- "strings"
-)
-
-func HTMLCellEscapeString(s string) template.HTML {
- html := template.HTMLEscapeString(s)
- if strings.TrimSpace(html) == "" {
- html = "&nbsp;"
- }
- return template.HTML(html)
-}