Documentation
¶
Index ¶
- Constants
- Variables
- func EraName(s string) eraName
- func WithCalendarID(cid ...CalendarID) optFunc
- func WithEndDate(end DateJp) optFunc
- func WithStartDate(start DateJp) optFunc
- func WithTempDir(dir string) optFunc
- type CalendarID
- type DateJp
- func (t DateJp) AddDate(years int, months int, days int) DateJp
- func (t DateJp) AddDay(days int) DateJp
- func (t DateJp) After(dt DateJp) bool
- func (t DateJp) Before(dt DateJp) bool
- func (t DateJp) Equal(dt DateJp) bool
- func (t DateJp) Era() eraName
- func (t *DateJp) MarshalJSON() ([]byte, error)
- func (t DateJp) String() string
- func (t *DateJp) UnmarshalJSON(b []byte) error
- func (t DateJp) YearEra() (eraName, int)
- func (t DateJp) YearEraString() (string, string)
- type Event
- type Koyomi
- type Source
Examples ¶
Constants ¶
const ( EraUnknown eraName = iota //不明な元号 Meiji //明治 Taisho //大正 Showa //昭和 Heisei //平成 Reiwa //令和 )
Variables ¶
var ( ErrNullPointer = errors.New("Null reference instance") ErrNoData = errors.New("No data") ErrInvalidRecord = errors.New("Invalid record") )
var (
JST = time.FixedZone("JST", int(jstoffset)) // Japan standard Time
)
Functions ¶
func EraName ¶ added in v0.4.0
func EraName(s string) eraName
koyomi.EraName() 関数は元号の文字列から元号名 eraName を取得します。 該当する元号名がない場合は era.Unknown を返します。
func WithCalendarID ¶
func WithCalendarID(cid ...CalendarID) optFunc
WithCalendarID returns function for setting Reader
func WithEndDate ¶
func WithEndDate(end DateJp) optFunc
WithEndDate returns function for setting Reader
func WithStartDate ¶
func WithStartDate(start DateJp) optFunc
WithStartDate returns function for setting Reader
func WithTempDir ¶
func WithTempDir(dir string) optFunc
WithTempDir returns function for setting Reader
Types ¶
type CalendarID ¶
type CalendarID int
const ( Holiday CalendarID = iota + 1 //国民の祝日および休日 MoonPhase //朔弦望 SolarTerm //二十四節気・雑節 Eclipse //日食・月食・日面経過 Planet //惑星現象 )
type DateJp ¶
DateJp is wrapper class of time.Time
func NewDateEra ¶ added in v0.4.0
koyomi.NewDateEra() 関数は 元号・年・月・日・時・分・秒・タイムゾーン を指定して koyomi.DateJp 型のインスタンスを返します。 起点が定義されない元号を指定した場合は西暦として処理します。
func (DateJp) AddDate ¶ added in v0.5.0
AddDate method adds years/months/days and returns new Date instance.
func (DateJp) Era ¶ added in v0.4.0
func (t DateJp) Era() eraName
koyomi.DateJp.Era() メソッドは元号名 koyomi.eraName のインスタンスを返します。 元号が不明の場合は era.Unknown を返します。
func (*DateJp) MarshalJSON ¶
MarshalJSON returns time string with RFC3339 format
func (*DateJp) UnmarshalJSON ¶
UnmarshalJSON returns result of Unmarshal for json.Unmarshal()
func (DateJp) YearEra ¶ added in v0.4.0
koyomi.DateJp.YearEra() メソッドは元号付きの年の値を返します。 元号が不明の場合は (era.Unknown, 0) を返します。
func (DateJp) YearEraString ¶ added in v0.4.0
koyomi.DateJp.YearEraString() メソッドは元号付きの年の値を文字列で返します。 元号が不明の場合は空文字列を返します。
type Koyomi ¶
type Koyomi struct {
// contains filtered or unexported fields
}
Koyomi is array of Event
Example ¶
package main
import (
"bytes"
"fmt"
"io"
"os"
"time"
"github.com/goark/koyomi"
)
func main() {
start, _ := koyomi.DateFrom("2019-05-01")
end := koyomi.NewDate(time.Date(2019, time.May, 31, 0, 0, 0, 0, koyomi.JST))
k, err := koyomi.NewSource(
koyomi.WithCalendarID(koyomi.Holiday, koyomi.SolarTerm),
koyomi.WithStartDate(start),
koyomi.WithEndDate(end),
).Get()
if err != nil {
return
}
csv, err := k.EncodeCSV()
if err != nil {
return
}
if _, err := io.Copy(os.Stdout, bytes.NewReader(csv)); err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
}
Output: "Date","Title" "2019-05-01","休日 (天皇の即位の日)" "2019-05-02","休日" "2019-05-02","八十八夜" "2019-05-03","憲法記念日" "2019-05-04","みどりの日" "2019-05-05","こどもの日" "2019-05-06","休日" "2019-05-06","立夏" "2019-05-21","小満"
