Documentation ¶
Index ¶
- Constants
- func IsTestNow() bool
- func SetTestNow(testTime Carbon)
- func SetTimezone(timezone string)
- func UnsetTestNow()
- type Carbon
- func FromDate(year int, month int, day int, timezone ...string) Carbon
- func FromDateMicro(year int, month int, day int, microsecond int, timezone ...string) Carbon
- func FromDateMilli(year int, month int, day int, millisecond int, timezone ...string) Carbon
- func FromDateNano(year int, month int, day int, nanosecond int, timezone ...string) Carbon
- func FromDateTime(year int, month int, day int, hour int, minute int, second int, ...) Carbon
- func FromDateTimeMicro(year int, month int, day int, hour int, minute int, second int, ...) Carbon
- func FromDateTimeMilli(year int, month int, day int, hour int, minute int, second int, ...) Carbon
- func FromDateTimeNano(year int, month int, day int, hour int, minute int, second int, nanosecond int, ...) Carbon
- func FromStdTime(time stdtime.Time) Carbon
- func FromTime(hour int, minute int, second int, timezone ...string) Carbon
- func FromTimeMicro(hour int, minute int, second int, microsecond int, timezone ...string) Carbon
- func FromTimeMilli(hour int, minute int, second int, millisecond int, timezone ...string) Carbon
- func FromTimeNano(hour int, minute int, second int, nanosecond int, timezone ...string) Carbon
- func FromTimestamp(timestamp int64, timezone ...string) Carbon
- func FromTimestampMicro(timestamp int64, timezone ...string) Carbon
- func FromTimestampMilli(timestamp int64, timezone ...string) Carbon
- func FromTimestampNano(timestamp int64, timezone ...string) Carbon
- func Now(timezone ...string) Carbon
- func Parse(value string, timezone ...string) Carbon
- func ParseByFormat(value, format string, timezone ...string) Carbon
- func ParseByLayout(value, layout string, timezone ...string) Carbon
- type Clock
- type Date
- type DateMicro
- type DateMilli
- type DateNano
- type DateTime
- type DateTimeMicro
- type DateTimeMilli
- type DateTimeNano
- type Timestamp
- type TimestampMicro
- type TimestampMilli
- type TimestampNano
Constants ¶
const ( Local = carbon.Local // 本地时间 UTC = carbon.UTC // 世界协调时间 GMT = carbon.GMT // 格林尼治标准时间 EET = carbon.EET // 欧洲东部标准时间 WET = carbon.WET // 欧洲西部标准时间 CET = carbon.CET // 欧洲中部标准时间 EST = carbon.EST // 美国东部标准时间 MST = carbon.MST // 美国山地标准时间 Cuba = carbon.Cuba // 古巴 Egypt = carbon.Egypt // 埃及 Eire = carbon.Eire // 爱尔兰 Greenwich = carbon.Greenwich // 格林尼治 Iceland = carbon.Iceland // 冰岛 Iran = carbon.Iran // 伊朗 Israel = carbon.Israel // 以色列 Jamaica = carbon.Jamaica // 牙买加 Japan = carbon.Japan // 日本 Libya = carbon.Libya // 利比亚 Poland = carbon.Poland // 波兰 Portugal = carbon.Portugal // 葡萄牙 PRC = carbon.PRC // 中国 Singapore = carbon.Singapore // 新加坡 Turkey = carbon.Turkey // 土耳其 Shanghai = carbon.Shanghai // 上海 Chongqing = carbon.Chongqing // 重庆 Harbin = carbon.Harbin // 哈尔滨 Urumqi = carbon.Urumqi // 乌鲁木齐 HongKong = carbon.HongKong // 香港 Macao = carbon.Macao // 澳门 Taipei = carbon.Taipei // 台北 Tokyo = carbon.Tokyo // 东京 Saigon = carbon.Saigon // 西贡 Seoul = carbon.Seoul // 首尔 Bangkok = carbon.Bangkok // 曼谷 Dubai = carbon.Dubai // 迪拜 NewYork = carbon.NewYork // 纽约 LosAngeles = carbon.LosAngeles // 洛杉矶 Chicago = carbon.Chicago // 芝加哥 Moscow = carbon.Moscow // 莫斯科 London = carbon.London // 伦敦 Berlin = carbon.Berlin // 柏林 Paris = carbon.Paris // 巴黎 Rome = carbon.Rome // 罗马 Sydney = carbon.Sydney // 悉尼 Melbourne = carbon.Melbourne // 墨尔本 Darwin = carbon.Darwin // 达尔文 )
timezone constants 时区常量
const ( January = carbon.January // 一月 February = carbon.February // 二月 March = carbon.March // 三月 April = carbon.April // 四月 May = carbon.May // 五月 June = carbon.June // 六月 July = carbon.July // 七月 August = carbon.August // 八月 September = carbon.September // 九月 October = carbon.October // 十月 November = carbon.November // 十一月 December = carbon.December // 十二月 )
month constants 月份常量
const ( Monday = carbon.Monday // 周一 Tuesday = carbon.Tuesday // 周二 Wednesday = carbon.Wednesday // 周三 Thursday = carbon.Thursday // 周四 Friday = carbon.Friday // 周五 Saturday = carbon.Saturday // 周六 Sunday = carbon.Sunday // 周日 )
week constants 星期常量
const ( YearsPerMillennium = 1000 // 每千年1000年 YearsPerCentury = 100 // 每世纪100年 YearsPerDecade = 10 // 每十年10年 QuartersPerYear = 4 // 每年4个季度 MonthsPerYear = 12 // 每年12月 MonthsPerQuarter = 3 // 每季度3月 WeeksPerNormalYear = 52 // 每常规年52周 WeeksPerMonth = 4 // 每月4周 DaysPerLeapYear = 366 // 每闰年366天 DaysPerNormalYear = 365 // 每常规年365天 DaysPerWeek = 7 // 每周7天 HoursPerWeek = 168 // 每周168小时 HoursPerDay = 24 // 每天24小时 MinutesPerDay = 1440 // 每天1440分钟 MinutesPerHour = 60 // 每小时60分钟 SecondsPerWeek = 604800 // 每周604800秒 SecondsPerDay = 86400 // 每天86400秒 SecondsPerHour = 3600 // 每小时3600秒 SecondsPerMinute = 60 // 每分钟60秒 )
number constants 数字常量
const ( ANSICLayout = stdtime.ANSIC UnixDateLayout = stdtime.UnixDate RubyDateLayout = stdtime.RubyDate RFC822Layout = stdtime.RFC822 RFC822ZLayout = stdtime.RFC822Z RFC850Layout = stdtime.RFC850 RFC1123Layout = stdtime.RFC1123 RFC1123ZLayout = stdtime.RFC1123Z RssLayout = stdtime.RFC1123Z KitchenLayout = stdtime.Kitchen RFC2822Layout = stdtime.RFC1123Z CookieLayout = carbon.CookieLayout RFC3339Layout = carbon.RFC3339Layout RFC3339MilliLayout = carbon.RFC3339MilliLayout RFC3339MicroLayout = carbon.RFC3339MicroLayout RFC3339NanoLayout = carbon.RFC3339NanoLayout ISO8601Layout = carbon.ISO8601Layout ISO8601MilliLayout = carbon.ISO8601MilliLayout ISO8601MicroLayout = carbon.ISO8601MicroLayout ISO8601NanoLayout = carbon.ISO8601NanoLayout RFC1036Layout = carbon.RFC1036Layout RFC7231Layout = carbon.RFC7231Layout DayDateTimeLayout = carbon.DayDateTimeLayout DateTimeLayout = carbon.DateTimeLayout DateTimeMilliLayout = carbon.DateTimeMilliLayout DateTimeMicroLayout = carbon.DateTimeMicroLayout DateTimeNanoLayout = carbon.DateTimeNanoLayout ShortDateTimeLayout = carbon.ShortDateTimeLayout ShortDateTimeMilliLayout = carbon.ShortDateTimeMilliLayout ShortDateTimeMicroLayout = carbon.ShortDateTimeMicroLayout ShortDateTimeNanoLayout = carbon.ShortDateTimeNanoLayout DateLayout = carbon.DateLayout DateMilliLayout = carbon.DateMilliLayout DateMicroLayout = carbon.DateMicroLayout DateNanoLayout = carbon.DateNanoLayout ShortDateLayout = carbon.ShortDateLayout ShortDateMilliLayout = carbon.ShortDateMilliLayout ShortDateMicroLayout = carbon.ShortDateMicroLayout ShortDateNanoLayout = carbon.ShortDateNanoLayout TimeLayout = carbon.TimeLayout TimeMilliLayout = carbon.TimeMilliLayout TimeMicroLayout = carbon.TimeMicroLayout TimeNanoLayout = carbon.TimeNanoLayout ShortTimeLayout = carbon.ShortTimeLayout ShortTimeMilliLayout = carbon.ShortTimeMilliLayout ShortTimeMicroLayout = carbon.ShortTimeMicroLayout ShortTimeNanoLayout = carbon.ShortTimeNanoLayout )
layout constants 布局模板常量
Variables ¶
This section is empty.
Functions ¶
func SetTestNow ¶
func SetTestNow(testTime Carbon)
SetTestNow Set the test time. Remember to unset after used.
Types ¶
type Carbon ¶
type Carbon = carbon.Carbon
func FromDateMicro ¶
FromDateMicro return a Carbon object of given microsecond date.
func FromDateMilli ¶
FromDateMilli return a Carbon object of given millisecond date.
func FromDateNano ¶
FromDateNano return a Carbon object of given nanosecond date.
func FromDateTime ¶
func FromDateTime(year int, month int, day int, hour int, minute int, second int, timezone ...string) Carbon
FromDateTime return a Carbon object of given date and time.
func FromDateTimeMicro ¶
func FromDateTimeMicro(year int, month int, day int, hour int, minute int, second int, microsecond int, timezone ...string) Carbon
FromDateTimeMicro return a Carbon object of given date and microsecond time.
func FromDateTimeMilli ¶
func FromDateTimeMilli(year int, month int, day int, hour int, minute int, second int, millisecond int, timezone ...string) Carbon
FromDateTimeMilli return a Carbon object of given date and millisecond time.
func FromDateTimeNano ¶
func FromDateTimeNano(year int, month int, day int, hour int, minute int, second int, nanosecond int, timezone ...string) Carbon
FromDateTimeNano return a Carbon object of given date and nanosecond time.
func FromStdTime ¶
FromStdTime return a Carbon object of given time.Time object.
func FromTimeMicro ¶
FromTimeMicro return a Carbon object of given microsecond time.
func FromTimeMilli ¶
FromTimeMilli return a Carbon object of given millisecond time.
func FromTimeNano ¶
FromTimeNano return a Carbon object of given nanosecond time.
func FromTimestamp ¶
FromTimestamp return a Carbon object of given timestamp.
func FromTimestampMicro ¶
FromTimestampMicro return a Carbon object of given microsecond timestamp.
func FromTimestampMilli ¶
FromTimestampMilli return a Carbon object of given millisecond timestamp.
func FromTimestampNano ¶
FromTimestampNano return a Carbon object of given nanosecond timestamp.
func ParseByFormat ¶
ParseByFormat return a Carbon object of given value and format.
func ParseByLayout ¶
ParseByLayout return a Carbon object of given value and layout.
type Date ¶
type Date struct {
Carbon
}
Date defines a Date struct. 定义 Date 结构体
func (Date) GormDataType ¶ added in v1.13.1
func (Date) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for Date struct. 实现 MarshalJSON 接口
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for Date struct. 实现 UnmarshalJSON 接口
type DateMicro ¶
type DateMicro struct {
Carbon
}
DateMicro defines a DateMicro struct. 定义 DateMicro 结构体
func NewDateMicro ¶
func (DateMicro) GormDataType ¶ added in v1.13.1
func (DateMicro) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for DateMicro struct. 实现 MarshalJSON 接口
func (DateMicro) String ¶
String implements the interface Stringer for DateMicro struct. 实现 Stringer 接口
func (*DateMicro) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for DateMicro struct. 实现 UnmarshalJSON 接口
type DateMilli ¶
type DateMilli struct {
Carbon
}
DateMilli defines a DateMilli struct. 定义 DateMilli 结构体
func NewDateMilli ¶
func (DateMilli) GormDataType ¶ added in v1.13.1
func (DateMilli) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for DateMilli struct. 实现 MarshalJSON 接口
func (DateMilli) String ¶
String implements the interface Stringer for DateMilli struct. 实现 Stringer 接口
func (*DateMilli) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for DateMilli struct. 实现 UnmarshalJSON 接口
type DateNano ¶
type DateNano struct {
Carbon
}
DateNano defines a DateNano struct. 定义 DateNano 结构体
func NewDateNano ¶
func (DateNano) GormDataType ¶ added in v1.13.1
func (DateNano) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for DateNano struct. 实现 MarshalJSON 接口
func (DateNano) String ¶
String implements the interface Stringer for DateNano struct. 实现 Stringer 接口
func (*DateNano) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for DateNano struct. 实现 UnmarshalJSON 接口
type DateTime ¶
type DateTime struct {
Carbon
}
DateTime defines a DateTime struct. 定义 DateTime 结构体
func NewDateTime ¶
func (DateTime) GormDataType ¶ added in v1.13.1
func (DateTime) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for DateTime struct. 实现 MarshalJSON 接口
func (DateTime) String ¶
String implements the interface Stringer for DateTime struct. 实现 Stringer 接口
func (*DateTime) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for DateTime struct. 实现 UnmarshalJSON 接口
type DateTimeMicro ¶
type DateTimeMicro struct {
Carbon
}
DateTimeMicro defines a DateTimeMicro struct. 定义 DateTimeMicro 结构体
func NewDateTimeMicro ¶
func NewDateTimeMicro(carbon Carbon) DateTimeMicro
func (DateTimeMicro) GormDataType ¶ added in v1.13.1
func (t DateTimeMicro) GormDataType() string
func (DateTimeMicro) MarshalJSON ¶
func (t DateTimeMicro) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface json.Marshal for DateTimeMicro struct. 实现 MarshalJSON 接口
func (DateTimeMicro) String ¶
func (t DateTimeMicro) String() string
String implements the interface Stringer for DateTimeMicro struct. 实现 Stringer 接口
func (*DateTimeMicro) UnmarshalJSON ¶
func (t *DateTimeMicro) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for DateTimeMicro struct. 实现 UnmarshalJSON 接口
type DateTimeMilli ¶
type DateTimeMilli struct {
Carbon
}
DateTimeMilli defines a DateTimeMilli struct. 定义 DateTimeMilli 结构体
func NewDateTimeMilli ¶
func NewDateTimeMilli(carbon Carbon) DateTimeMilli
func (DateTimeMilli) GormDataType ¶ added in v1.13.1
func (t DateTimeMilli) GormDataType() string
func (DateTimeMilli) MarshalJSON ¶
func (t DateTimeMilli) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface json.Marshal for DateTimeMilli struct. 实现 MarshalJSON 接口
func (DateTimeMilli) String ¶
func (t DateTimeMilli) String() string
String implements the interface Stringer for DateTimeMilli struct. 实现 Stringer 接口
func (*DateTimeMilli) UnmarshalJSON ¶
func (t *DateTimeMilli) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for DateTimeMilli struct. 实现 UnmarshalJSON 接口
type DateTimeNano ¶
type DateTimeNano struct {
Carbon
}
DateTimeNano defines a DateTimeNano struct. 定义 DateTimeNano 结构体
func NewDateTimeNano ¶
func NewDateTimeNano(carbon Carbon) DateTimeNano
func (DateTimeNano) GormDataType ¶ added in v1.13.1
func (t DateTimeNano) GormDataType() string
func (DateTimeNano) MarshalJSON ¶
func (t DateTimeNano) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface json.Marshal for DateTimeNano struct. 实现 MarshalJSON 接口
func (DateTimeNano) String ¶
func (t DateTimeNano) String() string
String implements the interface Stringer for DateTimeNano struct. 实现 Stringer 接口
func (*DateTimeNano) UnmarshalJSON ¶
func (t *DateTimeNano) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for DateTimeNano struct. 实现 UnmarshalJSON 接口
type Timestamp ¶
type Timestamp struct {
Carbon
}
Timestamp defines a Timestamp struct. 定义 Timestamp 结构体
func NewTimestamp ¶
func (Timestamp) GormDataType ¶ added in v1.13.1
func (Timestamp) MarshalJSON ¶
MarshalJSON implements the interface json.Marshal for Timestamp struct. 实现 MarshalJSON 接口
func (Timestamp) String ¶
String implements the interface Stringer for Timestamp struct. 实现 Stringer 接口
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the interface json.Unmarshal for Timestamp struct. 实现 UnmarshalJSON 接口
type TimestampMicro ¶
type TimestampMicro struct {
Carbon
}
TimestampMicro defines a TimestampMicro struct. 定义 TimestampMicro 结构体
func NewTimestampMicro ¶
func NewTimestampMicro(carbon Carbon) TimestampMicro
func (TimestampMicro) GormDataType ¶ added in v1.13.1
func (t TimestampMicro) GormDataType() string
func (TimestampMicro) MarshalJSON ¶
func (t TimestampMicro) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface MarshalJSON for TimestampMicro struct. 实现 MarshalJSON 接口
func (TimestampMicro) String ¶
func (t TimestampMicro) String() string
String implements the interface Stringer for TimestampMicro struct. 实现 Stringer 接口
func (*TimestampMicro) UnmarshalJSON ¶
func (t *TimestampMicro) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for TimestampMicro struct. 实现 UnmarshalJSON 接口
type TimestampMilli ¶
type TimestampMilli struct {
Carbon
}
TimestampMilli defines a TimestampMilli struct. 定义 TimestampMilli 结构体
func NewTimestampMilli ¶
func NewTimestampMilli(carbon Carbon) TimestampMilli
func (TimestampMilli) GormDataType ¶ added in v1.13.1
func (t TimestampMilli) GormDataType() string
func (TimestampMilli) MarshalJSON ¶
func (t TimestampMilli) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface json.Marshal for TimestampMilli struct. 实现 MarshalJSON 接口
func (TimestampMilli) String ¶
func (t TimestampMilli) String() string
String implements the interface Stringer for TimestampMilli struct. 实现 Stringer 接口
func (*TimestampMilli) UnmarshalJSON ¶
func (t *TimestampMilli) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for TimestampMilli struct. 实现 UnmarshalJSON 接口
type TimestampNano ¶
type TimestampNano struct {
Carbon
}
TimestampNano defines a TimestampNano struct. 定义 TimestampNano 结构体
func NewTimestampNano ¶
func NewTimestampNano(carbon Carbon) TimestampNano
func (TimestampNano) GormDataType ¶ added in v1.13.1
func (t TimestampNano) GormDataType() string
func (TimestampNano) MarshalJSON ¶
func (t TimestampNano) MarshalJSON() ([]byte, error)
MarshalJSON implements the interface json.Marshal for TimestampNano struct. 实现 MarshalJSON 接口
func (TimestampNano) String ¶
func (t TimestampNano) String() string
String implements the interface Stringer for TimestampNano struct. 实现 Stringer 接口
func (*TimestampNano) UnmarshalJSON ¶
func (t *TimestampNano) UnmarshalJSON(b []byte) error
UnmarshalJSON implements the interface json.Unmarshal for TimestampNano struct. 实现 UnmarshalJSON 接口