time

package
v0.0.0-...-7c10af5 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: LGPL-3.0 Imports: 7 Imported by: 0

README

##说明

  • m_Diff: 计算两个时间的时间差,单位秒
  • m_isToday: 查看是不是今天.
  • m_timeFormat: 获取格式化好的时间.
  • m_timesplit: 时间切割,参数单位秒。比如传61,返回(1,1),第一个表示分,第二个表示秒.

Documentation

Index

Constants

View Source
const (
	ZeroTime  = time.Second * 0
	OneSecond = time.Second * 1
	OneMinute = OneSecond * 60
	OneHour   = OneMinute * 60
	OneDay    = OneHour * 24
	OneWeek   = OneDay * 7
	OneYear   = OneDay * 365
)

当前页面,都是时间类型(time.Duration)的值,不做其他用途

Variables

This section is empty.

Functions

func AddDay

func AddDay(baseTime int64, days int) time.Time

增加天数

func AddHour

func AddHour(baseTime int64, hours int) time.Time

增加小时

func AddMinute

func AddMinute(baseTime int64, minutes int) time.Time

增加分钟

func AddMonth

func AddMonth(basetime int64, md int) time.Time

传入Unix时间戳,以及需要增加的月份数,返回一个新的时间对象

func AddSecond

func AddSecond(baseTime int64, second int) time.Time

增加秒

func CurrentTime

func CurrentTime() string

返回当前时间

func CurrentTimestamp

func CurrentTimestamp() int64

返回当前时间的时间戳

func ExecBashShell

func ExecBashShell(cmdLine string) (string, error)

执行系统命令

func FormatUnixTime

func FormatUnixTime(t int64) string

时间戳格式化为本地字符串

func GetData

func GetData() string

获取日期,不带时间

func GetDay

func GetDay(seconds int) (int, int, int, int)

第一个返回天数,第二个小时,第三个分钟,第四个秒

func GetFullTime

func GetFullTime() string

完整的日期和时间

func GetHour

func GetHour(seconds int) (int, int, int)

第一个返回小时,第二个分钟,第三个秒

func GetMinute

func GetMinute(seconds int) (int, int)

第一个返回值代表分,第二个返回值代表秒

func GetTime

func GetTime() string

获取时间,不带日期

func GetTimeZone

func GetTimeZone() int

获取当前的时区

func GetTimeZoneCity

func GetTimeZoneCity(num int) string

时区设置

func GetTimeZoneTime

func GetTimeZoneTime(timestamp int64, value int) time.Time

参数:时间戳,时区(-12到12)。获取相应时区的时间

func GetWeek

func GetWeek(seconds int) (int, int, int, int, int)

第一个返回周,第二个天,第三个小时,第四个分钟,第五个秒

func GetWeekDay

func GetWeekDay(Year, Month, Day string) string

获取日期相对的周几

func IsToday

func IsToday(newtime string) bool

func OneMonth

func OneMonth(year int, month int) (int, time.Duration, error)

传入年份,月份,获取当月有多少天

func SetLinuxSystemTime

func SetLinuxSystemTime(tt int64) error

设置系统时间

func SetLinuxTimeZone

func SetLinuxTimeZone(tz int) error

设置系统时区

func TimeDifference

func TimeDifference(oldTime, newTime string) int

func TimeZoneFormat

func TimeZoneFormat(value int) string

获取时区显示字符串

func TimestampToLocal

func TimestampToLocal(t int64) string

根据时间戳返回本地时间

func TrucHour

func TrucHour(baseTime int64) time.Time

向前取整小时【更大的时间单位,取整不能这样操作!】

Types

type FormatTime

type FormatTime struct {
	time.Time
}

func FormatStrTime

func FormatStrTime(time_str string) (*FormatTime, error)

字符串格式化为时间

func (*FormatTime) ToString

func (t *FormatTime) ToString() string

func (*FormatTime) ToUnix

func (t *FormatTime) ToUnix() int64

Jump to

Keyboard shortcuts

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