moon

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DaysIn

func DaysIn(y, m int) int

DaysIn 返回 y 年中 m 月的最大天数

func IsLeap

func IsLeap(year int) bool

IsLeap 返回 year 是否闰年

func Since

func Since(t Time) time.Duration

Since 返回自 t 以来经过时间。它是 Now().Sub(t) 的简写。

func Until

func Until(t Time) time.Duration

Until 返回直到 t 的持续时间。它是 t.Sub(Now()) 的简写。

Types

type Time

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

func Layout

func Layout(layout string, value string) (t Time)

Layout 返回忽略错误的 LayoutE()

func LayoutE

func LayoutE(layout string, value string) (Time, error)

LayoutE 通过 layout 和 value 解析并返回它所表示的时间

func New

func New(t time.Time) Time

func Now

func Now() Time

func Parse

func Parse(value string, loc ...*time.Location) Time

Parse 返回忽略错误的 ParseE()

func ParseE

func ParseE(value string, loc ...*time.Location) (t Time, err error)

ParseE 解析 value 并返回它所表示的时间

func Unix

func Unix(sec int64) Time

func UnixMicro

func UnixMicro(usec int64) Time

func UnixMilli

func UnixMilli(msec int64) Time

func UnixNano

func UnixNano(nsec int64) Time

func (Time) Add

func (t Time) Add(d time.Duration) Time

Add 返回 t + d 的时间

func (Time) AddDay

func (t Time) AddDay(d ...int) Time

func (Time) AddMonth

func (t Time) AddMonth(md ...int) Time

func (Time) AddWeek

func (t Time) AddWeek(n int) Time

func (Time) AddYear

func (t Time) AddYear(ymd ...int) Time

AddYear 添加 年[, 月[, 日]]。若不传 [天数] 则月份不会溢出。

func (Time) After

func (t Time) After(u Time) bool

After 返回 t 是否在 u 之后 (t > u)

func (Time) Before

func (t Time) Before(u Time) bool

Before 返回 t 是否在 u 之前 (t < u)

func (Time) Compare

func (t Time) Compare(u Time) int

Compare 比较 t 和 u。 如果 t 小于 u 则返回 -1;大于返回 1;等于返回 0。

func (Time) DateOnly

func (t Time) DateOnly() string

func (Time) DateTime

func (t Time) DateTime() string

func (Time) Day

func (t Time) Day() int

Day 返回 t 的天数

func (Time) Days

func (t Time) Days() int

Days 返回本月份的最大天数

func (Time) Equal

func (t Time) Equal(u Time) bool

Equal 返回 t == u

func (Time) Format

func (t Time) Format(layout string) string

func (Time) Go

func (t Time) Go(y int, md ...int) Time

Go 去 t.Year()+y 年 a[0] 月 a[1] 日。月、日均不溢出。 如果 [月、日] 为负数,则从最后的月、日开始偏移。

func (Time) GoDay

func (t Time) GoDay(d int) Time

func (Time) GoMonth

func (t Time) GoMonth(m int, d ...int) Time

func (Time) GoYear

func (t Time) GoYear(y int, md ...int) Time

GoYear 跟 Go() 一样,但是 y 指定去确切的年份而非偏移。

func (Time) Hour

func (t Time) Hour() int

Hour 返回 t 的小时

func (Time) In

func (t Time) In(loc *time.Location) Time

In 返回 loc 时区的 t

func (Time) InDays

func (t Time) InDays(u Time) int

InDays 返回 t 与 u 的天差

func (Time) InHours

func (t Time) InHours(u Time) int

InHours 返回 t 与 u 的时差

func (Time) InMillis

func (t Time) InMillis(u Time) int

InMillis 返回 t 与 u 毫秒差

func (Time) InMinutes

func (t Time) InMinutes(u Time) int

InMinutes 返回 t 与 u 的分差

func (Time) InSeconds

func (t Time) InSeconds(u Time) int

InSeconds 返回 t 与 u 的秒差

func (Time) InYears

func (t Time) InYears(u Time) int

InYears 返回 t 与 u 的年差

func (Time) IsZero

func (t Time) IsZero() bool

IsZero 返回 t 是否零时刻

func (Time) Local

func (t Time) Local() Time

Local 返回本地时区的 t

func (Time) Location

func (t Time) Location() *time.Location

Location 返回 t 关联的时区信息

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON 将 t 转为 JSON 字符串时调用

func (Time) Micro

func (t Time) Micro() int

Micro 返回 t 的微秒

func (Time) Milli

func (t Time) Milli() int

Milli 返回 t 的毫秒

func (Time) Minute

func (t Time) Minute() int

Minute 返回 t 的分钟

func (Time) Month

func (t Time) Month() int

Month 返回 t 的月份

func (Time) Nano

func (t Time) Nano() int

Nano 返回 t 的纳秒

func (*Time) Scan

func (t *Time) Scan(value any) error

Scan 由 DB 转到 Go 时调用

func (Time) Second

func (t Time) Second() int

Second 返回 t 的秒数

func (Time) StartDay

func (t Time) StartDay(d ...int) Time

StartDay +d 日的开始时间

func (Time) StartMonth

func (t Time) StartMonth(md ...int) Time

StartMonth +m 月后第 d 日的开始时间

func (Time) StartWeek

func (t Time) StartWeek(w ...int) Time

StartWeek 本周开始时间

func (Time) StartYear

func (t Time) StartYear(ymd ...int) Time

StartYear +y 年后第 m 月 d 日的开始时间

func (Time) String

func (t Time) String() string

func (Time) StringOr

func (t Time) StringOr(v string) string

func (Time) Sub

func (t Time) Sub(u Time) time.Duration

Sub 返回 t - u 的时间差

func (Time) Time

func (t Time) Time() time.Time

Time 返回 t 的 time.Time

func (Time) UTC

func (t Time) UTC() Time

UTC 返回 UTC 时区的 t

func (Time) Unix

func (t Time) Unix() int64

Unix 返回 t 的秒时间戳

func (Time) UnixMicro

func (t Time) UnixMicro() int64

UnixMicro 返回 t 的微秒时间戳

func (Time) UnixMilli

func (t Time) UnixMilli() int64

UnixMilli 返回 t 毫秒时间戳

func (Time) UnixNano

func (t Time) UnixNano() int64

UnixNano 返回 t 的纳秒时间戳

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON 将 JSON 字符串转为 t 时调用

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value 由 Go 转到 DB 时调用

func (Time) Weekday

func (t Time) Weekday() int

Weekday 返回 t 的星期

func (Time) Year

func (t Time) Year() int

Year 返回 t 的年份

func (Time) YearDay

func (t Time) YearDay() int

YearDay 返回 t 年份中的第几天,非闰年为 1-365,闰年为 1-366。

Jump to

Keyboard shortcuts

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