date

package module
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 3 Imported by: 0

README

date

日付処理を提供する go ライブラリ。

ドキュメント

go get github.com/thamaji/date

Documentation

Index

Constants

View Source
const DefaultLayout = "2006-01-02"

DefaultLayout は日付のデフォルトフォーマットを定義します。

Variables

This section is empty.

Functions

func Range added in v1.1.0

func Range(start, end Date) iter.Seq[Date]

Range は、指定された開始日(start)から終了日(end)までの連続した日付を生成するイテレータを返します。 イテレータには開始日(start)、終了日(end)を含みます。 `start` が `end` より前の場合は昇順に、後の場合は降順に日付を生成します。

func RangeWithIndex added in v1.4.0

func RangeWithIndex(start, end Date) iter.Seq2[Date, int]

RangeWithIndex は、指定された開始日(start)から終了日(end)までの日付と、そのインデックスを含むイテレータを返します。 イテレータには開始日(start)、終了日(end)を含みます。 `start` が `end` より前の場合は昇順に、後の場合は降順に日付を生成します。

func Since

func Since(date Date) int

Since は指定された日付から現在までの日数を返します。

func Until

func Until(date Date) int

Until は現在から指定された日付までの日数を返します。

Types

type Date

type Date struct {
	// contains filtered or unexported fields
}

Date は時刻情報を持たない日付を表します。

func FromTime

func FromTime(t time.Time) Date

FromTime は time.Time から Date を生成します。

func New

func New(year int, month time.Month, day int) Date

New は指定した年月日で Date を作成します。

func Now

func Now() Date

Now は現在の日付を返します。

func Parse

func Parse(layout, value string) (Date, error)

Parse は指定されたフォーマットで文字列を解析し、Date を返します。

func (Date) Add

func (d Date) Add(years int, months int, days int) Date

Add は指定された年、月、日を加算した新しい Date を返します。

func (Date) After

func (d Date) After(date Date) bool

After は d が指定した日付より後かどうかを判定します。

func (Date) AppendFormat

func (d Date) AppendFormat(b []byte, layout string) []byte

AppendFormat は、指定されたレイアウトでフォーマットされた日付をバイトスライスに追加します。

func (Date) Before

func (d Date) Before(date Date) bool

Before は d が指定した日付より前かどうかを判定します。

func (Date) Compare added in v1.2.0

func (d Date) Compare(date Date) int

Compare は d と指定された日付を比較し、-1, 0, 1 を返します。

func (Date) Day

func (d Date) Day() int

Day は、日を返します。

func (Date) Equal

func (d Date) Equal(date Date) bool

Equal は d と指定された日付が等しいかを判定します。

func (Date) Format

func (d Date) Format(layout string) string

Format は、指定されたレイアウトで日付をフォーマットします。

func (*Date) GobDecode

func (d *Date) GobDecode(data []byte) error

GobDecode は、バイナリデータから日付をデコードします。

func (Date) GobEncode

func (d Date) GobEncode() ([]byte, error)

GobEncode は、日付をバイナリ形式にエンコードします。

func (Date) ISOWeek

func (d Date) ISOWeek() (int, int)

ISOWeek は、ISO 8601 形式の年と週番号を返します。

func (Date) IsZero

func (d Date) IsZero() bool

IsZero は Date がゼロ値かどうかを判定します。

func (Date) MarshalBinary

func (d Date) MarshalBinary() ([]byte, error)

MarshalBinary は、日付をバイナリ形式にエンコードします。

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON は、日付を JSON 文字列にエンコードします。

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

MarshalText は、日付をテキスト形式にエンコードします。

func (Date) Month

func (d Date) Month() time.Month

Month は、月を返します。

func (*Date) SetDay added in v1.3.0

func (d *Date) SetDay(day int)

SetDay は、日を設定します。

func (*Date) SetMonth added in v1.3.0

func (d *Date) SetMonth(month time.Month)

SetMonth は、月を設定します。

func (*Date) SetYear added in v1.3.0

func (d *Date) SetYear(year int)

SetYear は、西暦年を設定します。

func (Date) String

func (d Date) String() string

String は、日付をデフォルトのフォーマットで文字列に変換します。

func (Date) Sub

func (d Date) Sub(date Date) int

Sub は2つの日付の差を日数で返します。

func (Date) Time

func (d Date) Time() time.Time

Time は Date を time.Time に変換します。

func (Date) TimeInLocation

func (d Date) TimeInLocation(loc *time.Location) time.Time

TimeInLocation は、指定されたタイムゾーンの 0 時間 0 分 0 秒の time.Time を返します。

func (*Date) UnmarshalBinary

func (d *Date) UnmarshalBinary(data []byte) error

UnmarshalBinary は、バイナリデータから日付をデコードします。

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON は、JSON 文字列から日付をデコードします。

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) error

UnmarshalText は、テキストから日付をデコードします。

func (Date) Weekday

func (d Date) Weekday() time.Weekday

Weekday は、日付の曜日を返します。

func (Date) YMD

func (d Date) YMD() (int, time.Month, int)

YMD は、西暦年、月、日をそれぞれ返します。

func (Date) Year

func (d Date) Year() int

Year は、西暦年を返します。

func (Date) YearDay

func (d Date) YearDay() int

YearDay は、その年の通算日(1月1日を1とする)を返します。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL