all repos — paprika @ ed37b272f5791d139f3031bd35c8b3c41592f356

go rewrite of taigabot

plugins/time/time.go (view raw)

 1package time
 2
 3import (
 4	"fmt"
 5	"time"
 6
 7	"github.com/zsefvlol/timezonemapper"
 8)
 9
10func getTimezone(lonlat [2]float64) string {
11	tz := timezonemapper.LatLngToTimezoneString(lonlat[1], lonlat[0])
12	return tz
13}
14
15func GetTime(lonlat [2]float64, label string) (string, error) {
16	loc, _ := time.LoadLocation(getTimezone(lonlat))
17	now := time.Now().In(loc)
18	pretty := now.Format("2006-02-01 03:04 PM")
19	out := fmt.Sprintf("\x02%s\x02: %s", label, pretty)
20	return out, nil
21}