cherryTime

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 3 Imported by: 8

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毫秒
	MicrosecondsPerMillisecond = 1000    // 每毫秒1000微秒
	MicrosecondsPerSecond      = 1000000 // 每秒1000000微秒

	WeeksPerLongYear = 53 // 每长年53周

	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 AddGlobalOffset

func AddGlobalOffset(second int)

func GetAbsValue

func GetAbsValue(value int64) int64

GetAbsValue 获取绝对值

func ParseByDuration

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

ParseByDuration 通过持续时间解析

func SetGlobalLocation

func SetGlobalLocation(name string) (err error)

func SubGlobalOffset

func SubGlobalOffset(second int)

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 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) 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) 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)

SetDay 设置日

func (*CherryTime) SetHour

func (c *CherryTime) SetHour(hour int)

SetHour 设置时

func (*CherryTime) SetMinute

func (c *CherryTime) SetMinute(minute int)

SetMinute 设置分

func (*CherryTime) SetMonth

func (c *CherryTime) SetMonth(month int)

SetMonth 设置月

func (*CherryTime) SetSecond

func (c *CherryTime) SetSecond(second int)

SetSecond 设置秒

func (*CherryTime) SetTimezone

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

func (*CherryTime) SetYear

func (c *CherryTime) SetYear(year int)

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) ToDateTimeFormat

func (c CherryTime) ToDateTimeFormat() string

ToDateTimeFormat 2006-01-02 15:04:05

func (CherryTime) ToMillisecond

func (c CherryTime) ToMillisecond() int64

func (CherryTime) ToShortDateFormat

func (c CherryTime) ToShortDateFormat() string

ToShortDateFormat 20060102

func (CherryTime) ToShortDateTimeFormat

func (c CherryTime) ToShortDateTimeFormat() string

ToShortDateTimeFormat 20060102150405

func (CherryTime) ToShortTimeFormat

func (c CherryTime) ToShortTimeFormat() string

ToShortTimeFormat 150405

func (CherryTime) ToTimeFormat

func (c CherryTime) ToTimeFormat() string

ToTimeFormat 15:04:05

func (CherryTime) ToTimestamp

func (c CherryTime) ToTimestamp() int64

ToTimestamp ToTimestampWithSecond的简称

func (CherryTime) ToTimestampWithMicrosecond

func (c CherryTime) ToTimestampWithMicrosecond() int64

ToTimestampWithMicrosecond 输出微秒级时间戳

func (CherryTime) ToTimestampWithMillisecond

func (c CherryTime) ToTimestampWithMillisecond() int64

ToTimestampWithMillisecond 输出毫秒级时间戳

func (CherryTime) ToTimestampWithNanosecond

func (c CherryTime) ToTimestampWithNanosecond() int64

ToTimestampWithNanosecond 输出纳秒级时间戳

func (CherryTime) ToTimestampWithSecond

func (c CherryTime) ToTimestampWithSecond() int64

ToTimestampWithSecond 输出秒级时间戳

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