Skip to content

Instantly share code, notes, and snippets.

@marcy
Created January 5, 2015 09:00
Show Gist options
  • Save marcy/bc72b8087011812e1a34 to your computer and use it in GitHub Desktop.
Save marcy/bc72b8087011812e1a34 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
var (
jaWeekdays = []string{"日", "月", "火", "水", "木", "金", "土"}
)
func jaWeekday(t time.Time) string {
return jaWeekdays[t.Weekday()]
}
func heisei(t time.Time) int {
return t.Year() - 2000 + 12
}
func main() {
now := time.Now()
fmt.Printf("平成%d年%d月%d日(%s)\n", heisei(now), now.Month(), now.Day(), jaWeekday(now))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment