all repos — paprika @ e4901c29247df262a725e344dcd03079c2923f5e

go rewrite of taigabot

plugins/time/time.go (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
package time

import (
	"fmt"
	"time"

	"github.com/zsefvlol/timezonemapper"
)

func getTimezone(lonlat [2]float64) string {
	tz := timezonemapper.LatLngToTimezoneString(lonlat[1], lonlat[0])
	return tz
}

func GetTime(lonlat [2]float64, label string) (string, error) {
	loc, _ := time.LoadLocation(getTimezone(lonlat))
	now := time.Now().In(loc)
	pretty := now.Format("2006-02-01 03:04 PM")
	out := fmt.Sprintf("\x02%s\x02: %s", label, pretty)
	return out, nil
}