3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Posted at

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 
}
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?