1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/masx200-the-way-to-go_ZH_CN

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
timezones.go 688
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
SoniaChoo Отправлено 15.10.2019 23:59 f462e39
// Output:
// Eastern Standard time
// Universal Greenwich time
// Central Standard time
package main
import "fmt"
type TZ int
const (
HOUR TZ = 60 * 60
UTC TZ = 0 * HOUR
EST TZ = -5 * HOUR
CST TZ = -6 * HOUR
)
var timeZones = map[TZ]string{
UTC: "Universal Greenwich time",
EST: "Eastern Standard time",
CST: "Central Standard time"}
func (tz TZ) String() string { // Method on TZ (not ptr)
if zone, ok := timeZones[tz]; ok {
return zone
}
return ""
}
func main() {
fmt.Println(EST) // Print* knows about method String() of type TZ
fmt.Println(0 * HOUR)
fmt.Println(-6 * HOUR)
}
/* Output:
Eastern Standard time
Universal Greenwich time
Central Standard time
*/

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/masx200-the-way-to-go_ZH_CN.git
git@api.gitlife.ru:oschina-mirror/masx200-the-way-to-go_ZH_CN.git
oschina-mirror
masx200-the-way-to-go_ZH_CN
masx200-the-way-to-go_ZH_CN
master