flyaways
5/21/2018 - 11:46 AM

time.go

package main

import (
	"fmt"
	"time"
)

const day = time.Duration(24) * time.Hour

func truncate(l string, timestamp string) {
	loc, _ := time.LoadLocation(l)
	n, _ := time.ParseInLocation("2006-01-02 15:04:05", timestamp, loc)
	n = n.Truncate(day)
	fmt.Printf("%s\t=\t%s\n", loc.String(), n.Format(time.RFC3339))
}

func main() {
	timestamp := "2018-05-18 07:04:05"

	truncate("America/Thule", timestamp)
	truncate("America/New_York", timestamp)
	truncate("Asia/Tokyo", timestamp)
	truncate("Asia/Chongqing", timestamp)
	truncate("Atlantic/Azores", timestamp)
	truncate("Europe/London", timestamp)
	truncate("Asia/Baku", timestamp)
	truncate("Asia/Urumqi", timestamp)
	truncate("Indian/Cocos", timestamp)

}