Skip to content

winterjung/go-timechart

Repository files navigation

go-timechart

Actions Status

Install

$ go get github.com/JungWinter/go-timechart

Usage

package main

import (
	"fmt"
	"time"

	"github.com/JungWinter/go-timechart"
)

func main() {
	f := timechart.NewHalfHourIncrementFormatter(timechart.NewUnicodeChar)
	ss := []timechart.Schedule{
		{
			timechart.NewTime(0, 30, 0),
			timechart.NewTime(5, 30, 0),
		},
	}
	got := f.Format(ss)
	fmt.Println(got)

	// Output: ├─━┿━━┿━━┿━━┿━━┿━─┼──┼──┼──┼──┼──┼──┤├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤

	now := time.Date(2022, 2, 1, 10, 0, 0, 0, time.UTC)

	got = f.FormatWithTime(ss, now)
	fmt.Println(got)

	// Output: ├─━┿━━┿━━┿━━┿━━┿━─┼──┼──┼──┼──╂──┼──┤├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
}

About

Make timechart (ascii, unicode)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published