Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

Go言語用和暦ライブラリを作りました

Go言語用和暦ライブラリを作りました。
よかったら使ってみてください。

使い方

ライブラリを取得

$ cd $GOPATH
$ go get github.com/hideshi/go-wareki

サンプル

package main

import (
    "time"
    "fmt"
    "github.com/hideshi/go-wareki"
)

func main() {
    // Go言語バージョン1のリリース日
    firstReleaseDateOfMajorVersionOfGolang := time.Date(2012, 3, 28, 0, 0, 0, 0, time.UTC)

    // 和暦を取得
    wareki := wareki.NewWareki(firstReleaseDateOfMajorVersionOfGolang)

    // 和暦の文字列を取得
    fmt.Println(wareki.String()) // 平成24年3月28日
    fmt.Printf("%s\n", wareki) // 平成24年3月28日

    // 和暦から西暦の日付を取得
    d := wareki.Date // time.Time型
    fmt.Printf("%v\n", d) // 2012-03-28 00:00:00 +0000 UTC 
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What are the problem?