cherryTime

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 4 Imported by: 7

Documentation

Overview

Package cherryTime code from: https://github.com/golang-module/carbon

Index

Constants

View Source
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秒
	MillisecondsPerSecond      = 1000     // 每秒1000毫秒
	MillisecondsPerMinute      = 60000    // 每分钟60000毫秒
	MillisecondsPerDay         = 86400000 // 每天86400000毫秒
	MillisecondsPerHour        = 3600000  // 每小时3600000毫秒
	MicrosecondsPerMillisecond = 1000     // 每毫秒1000微秒
	MicrosecondsPerSecond      = 1000000  // 每秒1000000微秒

	WeeksPerLongYear = 53 // 每长年53周

	DateTimeMillisecondFormat = "2006-01-02 15:04:05.000"
	DateTimeFormat            = "2006-01-02 15:04:05"
	DateFormat                = "2006-01-02"
	TimeFormat                = "15:04:05"
	ShortDateTimeFormat       = "20060102150405"
	ShortDateFormat           = "20060102"
	ShortTimeFormat           = "150405"
)

Variables

This section is empty.

Functions

func AddOffsetTime added in v1.1.22

func AddOffsetTime(t time.Duration)

func GetAbsValue

func GetAbsValue(value int64) int64

GetAbsValue 获取绝对值

func ParseByDuration

func ParseByDuration(duration string) (time.Duration, error)

ParseByDuration 通过持续时间解析

func SetOffsetLocation added in v1.1.22

func SetOffsetLocation(name string) (err error)

func SubOffsetTime added in v1.1.22

func SubOffsetTime(t time.Duration)

Types

type CherryTime

type CherryTime struct {
	time.Time
}

func CreateFromDate

func CreateFromDate(year int, month int, day int) CherryTime

CreateFromDate 从年月日创建 Carbon 实例(默认时区)

func CreateFromDateTime

func CreateFromDateTime(year int, month int, day int, hour int, minute int, second int) CherryTime

CreateFromDateTime 从年月日时分秒创建 Carbon 实例

func CreateFromTime

func CreateFromTime(hour int, minute int, second int) CherryTime

CreateFromTime 从时分秒创建 Carbon 实例(默认时区)

func CreateFromTimestamp

func CreateFromTimestamp(timestamp int64) CherryTime

CreateFromTimestamp 从时间戳创建 Carbon 实例

func NewMillisecond added in v1.1.24

func NewMillisecond(millisecond int64) CherryTime

func NewSecond added in v1.1.24

func NewSecond(second int64) CherryTime

func NewTime

func NewTime(tt time.Time, setGlobal bool) CherryTime

func Now

func Now() CherryTime

func Tomorrow

func Tomorrow() CherryTime

func Yesterday

func Yesterday() CherryTime

func (*CherryTime) AddCenturies

func (c *CherryTime) AddCenturies(centuries int)

AddCenturies N世纪后

func (*CherryTime) AddCenturiesNoOverflow

func (c *CherryTime) AddCenturiesNoOverflow(centuries int)

AddCenturiesNoOverflow N世纪后(月份不溢出)

func (*CherryTime) AddCentury

func (c *CherryTime) AddCentury()

AddCentury 1世纪后

func (*CherryTime) AddCenturyNoOverflow

func (c *CherryTime) AddCenturyNoOverflow()

AddCenturyNoOverflow 1世纪后(月份不溢出)

func (*CherryTime) AddDay

func (c *CherryTime) AddDay()

AddDay 1天后

func (*CherryTime) AddDays

func (c *CherryTime) AddDays(days int)

AddDays N天后

func (*CherryTime) AddDuration

func (c *CherryTime) AddDuration(duration string) error

AddDuration 按照持续时间字符串增加时间 支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合

func (*CherryTime) AddHour

func (c *CherryTime) AddHour()

AddHour 1小时后

func (*CherryTime) AddHours

func (c *CherryTime) AddHours(hours int)

AddHours N小时后

func (*CherryTime) AddMinute

func (c *CherryTime) AddMinute()

AddMinute 1分钟后

func (*CherryTime) AddMinutes

func (c *CherryTime) AddMinutes(minutes int)

AddMinutes N分钟后

func (*CherryTime) AddMonth

func (c *CherryTime) AddMonth()

AddMonth 1月后

func (*CherryTime) AddMonthNoOverflow

func (c *CherryTime) AddMonthNoOverflow()

AddMonthNoOverflow 1月后(月份不溢出)

func (*CherryTime) AddMonths

func (c *CherryTime) AddMonths(months int)

AddMonths N月后

func (*CherryTime) AddMonthsNoOverflow

func (c *CherryTime) AddMonthsNoOverflow(months int)

AddMonthsNoOverflow N月后(月份不溢出)

func (*CherryTime) AddQuarter

func (c *CherryTime) AddQuarter()

AddQuarter 1季度后

func (*CherryTime) AddQuarterNoOverflow

func (c *CherryTime) AddQuarterNoOverflow()

AddQuarterNoOverflow 1季度后(月份不溢出)

func (*CherryTime) AddQuarters

func (c *CherryTime) AddQuarters(quarters int)

AddQuarters N季度后

func (*CherryTime) AddQuartersNoOverflow

func (c *CherryTime) AddQuartersNoOverflow(quarters int)

AddQuartersNoOverflow N季度后(月份不溢出)

func (*CherryTime) AddSecond

func (c *CherryTime) AddSecond()

AddSecond 1秒钟后

func (*CherryTime) AddSeconds

func (c *CherryTime) AddSeconds(seconds int)

AddSeconds N秒钟后

func (*CherryTime) AddWeek

func (c *CherryTime) AddWeek()

AddWeek 1天后

func (*CherryTime) AddWeeks

func (c *CherryTime) AddWeeks(weeks int)

AddWeeks N周后

func (*CherryTime) AddYear

func (c *CherryTime) AddYear()

AddYear 1年后

func (*CherryTime) AddYearNoOverflow

func (c *CherryTime) AddYearNoOverflow()

AddYearNoOverflow 1年后(月份不溢出)

func (*CherryTime) AddYears

func (c *CherryTime) AddYears(years int)

AddYears N年后

func (*CherryTime) AddYearsNoOverflow

func (c *CherryTime) AddYearsNoOverflow(years int)

AddYearsNoOverflow N年后(月份不溢出)

func (CherryTime) Day

func (c CherryTime) Day() int

Day 获取当前日

func (CherryTime) DayOfMonth

func (c CherryTime) DayOfMonth() int

DayOfMonth 获取本月的第几天(从1开始)

func (CherryTime) DayOfWeek

func (c CherryTime) DayOfWeek() int

DayOfWeek 获取本周的第几天(从1开始)

func (CherryTime) DayOfYear

func (c CherryTime) DayOfYear() int

DayOfYear 获取本年的第几天(从1开始)

func (CherryTime) DaysInMonth

func (c CherryTime) DaysInMonth() int

DaysInMonth 获取本月的总天数

func (CherryTime) DaysInYear

func (c CherryTime) DaysInYear() int

DaysInYear 获取本年的总天数

func (CherryTime) DiffINanosecond added in v1.2.3

func (c CherryTime) DiffINanosecond(end CherryTime) int64

DiffINanosecond 相关多少纳秒

func (CherryTime) DiffInDays

func (c CherryTime) DiffInDays(end CherryTime) int64

DiffInDays 相差多少天

func (CherryTime) DiffInDaysWithAbs

func (c CherryTime) DiffInDaysWithAbs(end CherryTime) int64

DiffInDaysWithAbs 相差多少天(绝对值)

func (CherryTime) DiffInHours

func (c CherryTime) DiffInHours(end CherryTime) int64

DiffInHours 相差多少小时

func (CherryTime) DiffInHoursWithAbs

func (c CherryTime) DiffInHoursWithAbs(end CherryTime) int64

DiffInHoursWithAbs 相差多少小时(绝对值)

func (CherryTime) DiffInMicrosecond added in v1.2.3

func (c CherryTime) DiffInMicrosecond(end CherryTime) int64

DiffInMicrosecond 相关多少微秒

func (CherryTime) DiffInMillisecond added in v1.1.22

func (c CherryTime) DiffInMillisecond(end CherryTime) int64

DiffInMillisecond 相差多少毫秒

func (CherryTime) DiffInMinutes

func (c CherryTime) DiffInMinutes(end CherryTime) int64

DiffInMinutes 相差多少分钟

func (CherryTime) DiffInMinutesWithAbs

func (c CherryTime) DiffInMinutesWithAbs(end CherryTime) int64

DiffInMinutesWithAbs 相差多少分钟(绝对值)

func (CherryTime) DiffInMonths

func (c CherryTime) DiffInMonths(end CherryTime) int64

DiffInMonths 相差多少月

func (CherryTime) DiffInMonthsWithAbs

func (c CherryTime) DiffInMonthsWithAbs(end CherryTime) int64

DiffInMonthsWithAbs 相差多少月(绝对值)

func (CherryTime) DiffInSeconds

func (c CherryTime) DiffInSeconds(end CherryTime) int64

DiffInSeconds 相差多少秒

func (CherryTime) DiffInSecondsWithAbs

func (c CherryTime) DiffInSecondsWithAbs(end CherryTime) int64

DiffInSecondsWithAbs 相差多少秒(绝对值)

func (CherryTime) DiffInWeeks

func (c CherryTime) DiffInWeeks(end CherryTime) int64

DiffInWeeks 相差多少周

func (CherryTime) DiffInWeeksWithAbs

func (c CherryTime) DiffInWeeksWithAbs(end CherryTime) int64

DiffInWeeksWithAbs 相差多少周(绝对值)

func (CherryTime) DiffInYears

func (c CherryTime) DiffInYears(end CherryTime) int64

DiffInYears 相差多少年

func (CherryTime) DiffInYearsWithAbs

func (c CherryTime) DiffInYearsWithAbs(end CherryTime) int64

DiffInYearsWithAbs 相差多少年(绝对值)

func (CherryTime) EndOfDay

func (c CherryTime) EndOfDay() time.Time

EndOfDay 本日结束时间

func (CherryTime) EndOfHour

func (c CherryTime) EndOfHour() time.Time

EndOfHour 小时结束时间

func (CherryTime) EndOfMinute

func (c CherryTime) EndOfMinute() time.Time

EndOfMinute 分钟结束时间

func (CherryTime) EndOfMonth

func (c CherryTime) EndOfMonth() time.Time

EndOfMonth 本月结束时间

func (CherryTime) EndOfSecond

func (c CherryTime) EndOfSecond() time.Time

EndOfSecond 秒结束时间

func (CherryTime) EndOfWeek

func (c CherryTime) EndOfWeek() time.Time

EndOfWeek 本周结束时间

func (CherryTime) EndOfYear

func (c CherryTime) EndOfYear() time.Time

EndOfYear 本年结束时间

func (CherryTime) Hour

func (c CherryTime) Hour() int

Hour 获取当前小时

func (CherryTime) IsApril

func (c CherryTime) IsApril() bool

IsApril 是否是四月

func (CherryTime) IsAugust

func (c CherryTime) IsAugust() bool

IsAugust 是否是八月

func (CherryTime) IsDecember

func (c CherryTime) IsDecember() bool

IsDecember 是否是十二月

func (CherryTime) IsFebruary

func (c CherryTime) IsFebruary() bool

IsFebruary 是否是二月

func (CherryTime) IsFriday

func (c CherryTime) IsFriday() bool

IsFriday 是否是周五

func (CherryTime) IsFuture

func (c CherryTime) IsFuture() bool

IsFuture 是否是未来时间

func (CherryTime) IsJanuary

func (c CherryTime) IsJanuary() bool

IsJanuary 是否是一月

func (CherryTime) IsJuly

func (c CherryTime) IsJuly() bool

IsJuly 是否是七月

func (CherryTime) IsJune

func (c CherryTime) IsJune() bool

IsJune 是否是六月

func (CherryTime) IsLeapYear

func (c CherryTime) IsLeapYear() bool

IsLeapYear 是否是闰年

func (CherryTime) IsLongYear

func (c CherryTime) IsLongYear() bool

IsLongYear 是否是长年

func (CherryTime) IsMarch

func (c CherryTime) IsMarch() bool

IsMarch 是否是三月

func (CherryTime) IsMay

func (c CherryTime) IsMay() bool

IsMay 是否是五月

func (CherryTime) IsMonday

func (c CherryTime) IsMonday() bool

IsMonday 是否是周一

func (CherryTime) IsNovember

func (c CherryTime) IsNovember() bool

IsNovember 是否是十一月

func (CherryTime) IsNow

func (c CherryTime) IsNow() bool

IsNow 是否是当前时间

func (CherryTime) IsOctober

func (c CherryTime) IsOctober() bool

IsOctober 是否是十月

func (CherryTime) IsPast

func (c CherryTime) IsPast() bool

IsPast 是否是过去时间

func (CherryTime) IsSaturday

func (c CherryTime) IsSaturday() bool

IsSaturday 是否是周六

func (CherryTime) IsSeptember

func (c CherryTime) IsSeptember() bool

IsSeptember 是否是九月

func (CherryTime) IsSunday

func (c CherryTime) IsSunday() bool

IsSunday 是否是周日

func (CherryTime) IsThursday

func (c CherryTime) IsThursday() bool

IsThursday 是否是周四

func (CherryTime) IsToday

func (c CherryTime) IsToday() bool

IsToday 是否是今天

func (CherryTime) IsTomorrow

func (c CherryTime) IsTomorrow() bool

IsTomorrow 是否是明天

func (CherryTime) IsTuesday

func (c CherryTime) IsTuesday() bool

IsTuesday 是否是周二

func (CherryTime) IsWednesday

func (c CherryTime) IsWednesday() bool

IsWednesday 是否是周三

func (CherryTime) IsWeekday

func (c CherryTime) IsWeekday() bool

IsWeekday 是否是工作日

func (CherryTime) IsWeekend

func (c CherryTime) IsWeekend() bool

IsWeekend 是否是周末

func (CherryTime) IsYesterday

func (c CherryTime) IsYesterday() bool

IsYesterday 是否是昨天

func (CherryTime) Microsecond

func (c CherryTime) Microsecond() int

Microsecond 获取当前微秒数

func (CherryTime) Millisecond

func (c CherryTime) Millisecond() int

Millisecond 获取当前毫秒数

func (CherryTime) Minute

func (c CherryTime) Minute() int

Minute 获取当前分钟数

func (CherryTime) Month

func (c CherryTime) Month() int

Month 获取当前月

func (CherryTime) MonthOfYear

func (c CherryTime) MonthOfYear() int

MonthOfYear 获取本年的第几月(从1开始)

func (CherryTime) Nanosecond

func (c CherryTime) Nanosecond() int

Nanosecond 获取当前纳秒数

func (CherryTime) Quarter

func (c CherryTime) Quarter() int

Quarter 获取当前季度

func (CherryTime) Second

func (c CherryTime) Second() int

Second 获取当前秒数

func (CherryTime) SetDay

func (c CherryTime) SetDay(day int) CherryTime

SetDay 设置日

func (CherryTime) SetHour

func (c CherryTime) SetHour(hour int) CherryTime

SetHour 设置时

func (CherryTime) SetMinute

func (c CherryTime) SetMinute(minute int) CherryTime

SetMinute 设置分

func (CherryTime) SetMonth

func (c CherryTime) SetMonth(month int) CherryTime

SetMonth 设置月

func (CherryTime) SetNanoSecond added in v1.1.22

func (c CherryTime) SetNanoSecond(nanoSecond int) CherryTime

SetNanoSecond 设置纳秒

func (CherryTime) SetSecond

func (c CherryTime) SetSecond(second int) CherryTime

SetSecond 设置秒

func (*CherryTime) SetTimezone

func (c *CherryTime) SetTimezone(timezone string) error

func (CherryTime) SetYear

func (c CherryTime) SetYear(year int) CherryTime

SetYear 设置年

func (CherryTime) StartOfDay

func (c CherryTime) StartOfDay() time.Time

StartOfDay 本日开始时间

func (CherryTime) StartOfHour

func (c CherryTime) StartOfHour() time.Time

StartOfHour 小时开始时间

func (CherryTime) StartOfMinute

func (c CherryTime) StartOfMinute() time.Time

StartOfMinute 分钟开始时间

func (CherryTime) StartOfMonth

func (c CherryTime) StartOfMonth() time.Time

StartOfMonth 本月开始时间

func (CherryTime) StartOfSecond

func (c CherryTime) StartOfSecond() time.Time

StartOfSecond 秒开始时间

func (CherryTime) StartOfWeek

func (c CherryTime) StartOfWeek() time.Time

StartOfWeek 本周开始时间

func (CherryTime) StartOfYear

func (c CherryTime) StartOfYear() time.Time

StartOfYear 本年开始时间

func (*CherryTime) SubCenturies

func (c *CherryTime) SubCenturies(centuries int)

SubCenturies N世纪前

func (*CherryTime) SubCenturiesNoOverflow

func (c *CherryTime) SubCenturiesNoOverflow(centuries int)

SubCenturiesNoOverflow N世纪前(月份不溢出)

func (*CherryTime) SubCentury

func (c *CherryTime) SubCentury()

SubCentury 1世纪前

func (*CherryTime) SubCenturyNoOverflow

func (c *CherryTime) SubCenturyNoOverflow()

SubCenturyNoOverflow 1世纪前(月份不溢出)

func (*CherryTime) SubDay

func (c *CherryTime) SubDay()

SubDay 1天前

func (*CherryTime) SubDays

func (c *CherryTime) SubDays(days int)

SubDays N天前

func (*CherryTime) SubDuration

func (c *CherryTime) SubDuration(duration string) error

SubDuration 按照持续时间字符串减少时间 支持整数/浮点数和符号ns(纳秒)、us(微妙)、ms(毫秒)、s(秒)、m(分钟)、h(小时)的组合

func (*CherryTime) SubHour

func (c *CherryTime) SubHour()

SubHour 1小时前

func (*CherryTime) SubHours

func (c *CherryTime) SubHours(hours int)

SubHours N小时前

func (*CherryTime) SubMinute

func (c *CherryTime) SubMinute()

SubMinute 1分钟前

func (*CherryTime) SubMinutes

func (c *CherryTime) SubMinutes(minutes int)

SubMinutes N分钟前

func (*CherryTime) SubMonth

func (c *CherryTime) SubMonth()

SubMonth 1月前

func (*CherryTime) SubMonthNoOverflow

func (c *CherryTime) SubMonthNoOverflow()

SubMonthNoOverflow 1月前(月份不溢出)

func (*CherryTime) SubMonths

func (c *CherryTime) SubMonths(months int)

SubMonths N月前

func (*CherryTime) SubMonthsNoOverflow

func (c *CherryTime) SubMonthsNoOverflow(months int)

SubMonthsNoOverflow N月前(月份不溢出)

func (*CherryTime) SubQuarter

func (c *CherryTime) SubQuarter()

SubQuarter 1季度前

func (*CherryTime) SubQuarterNoOverflow

func (c *CherryTime) SubQuarterNoOverflow()

SubQuarterNoOverflow 1季度前(月份不溢出)

func (*CherryTime) SubQuarters

func (c *CherryTime) SubQuarters(quarters int)

SubQuarters N季度前

func (*CherryTime) SubQuartersNoOverflow

func (c *CherryTime) SubQuartersNoOverflow(quarters int)

SubQuartersNoOverflow N季度前(月份不溢出)

func (*CherryTime) SubSecond

func (c *CherryTime) SubSecond()

SubSecond 1秒钟前

func (*CherryTime) SubSeconds

func (c *CherryTime) SubSeconds(seconds int)

SubSeconds N秒钟前

func (*CherryTime) SubWeek

func (c *CherryTime) SubWeek()

SubWeek 1天后

func (*CherryTime) SubWeeks

func (c *CherryTime) SubWeeks(weeks int)

SubWeeks N周后

func (*CherryTime) SubYear

func (c *CherryTime) SubYear()

SubYear 1年前

func (*CherryTime) SubYearNoOverflow

func (c *CherryTime) SubYearNoOverflow()

SubYearNoOverflow 1年前(月份不溢出)

func (*CherryTime) SubYears

func (c *CherryTime) SubYears(years int)

SubYears N年前

func (*CherryTime) SubYearsNoOverflow

func (c *CherryTime) SubYearsNoOverflow(years int)

SubYearsNoOverflow N年前(月份不溢出)

func (CherryTime) Timezone

func (c CherryTime) Timezone() string

Timezone 获取时区

func (CherryTime) ToDateFormat

func (c CherryTime) ToDateFormat() string

ToDateFormat 2006-01-02

func (CherryTime) ToDateMillisecondFormat added in v1.3.2

func (c CherryTime) ToDateMillisecondFormat() string

ToDateMillisecondFormat 2023-04-10 12:26:57.420

func (CherryTime) ToDateTimeFormat

func (c CherryTime) ToDateTimeFormat() string

ToDateTimeFormat 2006-01-02 15:04:05

func (CherryTime) ToMicrosecond added in v1.1.29

func (c CherryTime) ToMicrosecond() int64

ToMicrosecond 输出微秒级时间戳

func (CherryTime) ToMillisecond

func (c CherryTime) ToMillisecond() int64

ToMillisecond 输出毫秒级时间戳

func (CherryTime) ToMillisecondString added in v1.1.29

func (c CherryTime) ToMillisecondString() string

func (CherryTime) ToNanosecond added in v1.1.29

func (c CherryTime) ToNanosecond() int64

ToNanosecond 输出纳秒级时间戳

func (CherryTime) ToSecond added in v1.1.29

func (c CherryTime) ToSecond() int64

ToSecond 输出秒级时间戳

func (CherryTime) ToShortDateFormat

func (c CherryTime) ToShortDateFormat() string

ToShortDateFormat 20060102

func (CherryTime) ToShortDateTimeFormat

func (c CherryTime) ToShortDateTimeFormat() string

ToShortDateTimeFormat 20060102150405

func (CherryTime) ToShortIntDateFormat added in v1.1.22

func (c CherryTime) ToShortIntDateFormat() int32

ToShortIntDateFormat 20060102

func (CherryTime) ToShortTimeFormat

func (c CherryTime) ToShortTimeFormat() string

ToShortTimeFormat 150405

func (CherryTime) ToTimeFormat

func (c CherryTime) ToTimeFormat() string

ToTimeFormat 15:04:05

func (CherryTime) Week

func (c CherryTime) Week() int

Week 获取当前周(从0开始)

func (CherryTime) WeekOfMonth

func (c CherryTime) WeekOfMonth() int

WeekOfMonth 获取本月的第几周(从1开始)

func (CherryTime) WeekOfYear

func (c CherryTime) WeekOfYear() int

WeekOfYear 获取本年的第几周(从1开始)

func (CherryTime) Year

func (c CherryTime) Year() int

Year 获取当前年

Jump to

Keyboard shortcuts

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