package util

import (
	"fmt"
	"time"
)

// ConvertTimeToStringByUTCOffset converts time to string by UTC offset
// e.g. 2023-05-02 19:00:00
// May 2, 2023 18:00 UTC-01:00
// May 2, 2023 19:00 UTC±00:00
// May 3, 2023 03:00 UTC+08:00
func ConvertTimeToStringByUTCOffset(t time.Time, offset int32) string {
	location := time.FixedZone("UTC", int(offset)*3600)
	t = t.In(location)
	var sign string
	if offset > 0 {
		sign = "+"
	} else if offset < 0 {
		sign = "-"
		offset = -offset
	} else {
		sign = "±"
	}
	return fmt.Sprintf("%s UTC%s%02d:00", t.Format("Jan 2, 2006 15:04"), sign, offset)
}
