datetime

package
v0.0.0-...-9a41f76 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package datetime 实现了一些格式化日期和时间的功能 Note: 1. `format` param in FormatTimeToStr function should be as flow: "yyyy-mm-dd hh:mm:ss" "yyyy-mm-dd hh:mm" "yyyy-mm-dd hh" "yyyy-mm-dd" "yyyy-mm" "mm-dd" "dd-mm-yy hh:mm:ss" "yyyy/mm/dd hh:mm:ss" "yyyy/mm/dd hh:mm" "yyyy/mm/dd hh" "yyyy/mm/dd" "yyyy/mm" "mm/dd" "dd/mm/yy hh:mm:ss" "yyyy" "mm" "hh:mm:ss" "mm:ss"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDay

func AddDay(t time.Time, day int64) time.Time

AddDay 加或减天的时间

func AddHour

func AddHour(t time.Time, hour int64) time.Time

AddHour 加或减小时的时间

func AddMinute

func AddMinute(t time.Time, minute int64) time.Time

AddMinute 加或减分钟的时间

func BeginOfDay

func BeginOfDay(t time.Time) time.Time

BeginOfDay 返回开始时间 一天中的时间

func BeginOfHour

func BeginOfHour(t time.Time) time.Time

BeginOfHour 返回开始时间 一天中的时间

func BeginOfMinute

func BeginOfMinute(t time.Time) time.Time

BeginOfMinute 返回起始分钟的时间

func BeginOfMonth

func BeginOfMonth(t time.Time) time.Time

BeginOfMonth 月初返回

func BeginOfWeek

func BeginOfWeek(t time.Time) time.Time

BeginOfWeek 回归周,从周日开始的一周

func BeginOfYear

func BeginOfYear(t time.Time) time.Time

BeginOfYear 年初回报

func EndOfDay

func EndOfDay(t time.Time) time.Time

EndOfDay 一天中的返回结束时间

func EndOfHour

func EndOfHour(t time.Time) time.Time

EndOfHour 返回结束时间 一天中的时间

func EndOfMinute

func EndOfMinute(t time.Time) time.Time

EndOfMinute 返回结束时的时间

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

EndOfMonth 月末返回

func EndOfWeek

func EndOfWeek(t time.Time) time.Time

EndOfWeek 周末返程时间,周末有周六

func EndOfYear

func EndOfYear(t time.Time) time.Time

EndOfYear 年终回报

func FormatStrToTime

func FormatStrToTime(str, format string) (time.Time, error)

FormatStrToTime 将字符串转换为时间

func FormatTimeToStr

func FormatTimeToStr(t time.Time, format string) string

FormatTimeToStr 将时间转换为字符串

func GetNightTimestamp

func GetNightTimestamp() int64

GetNightTimestamp 返回零时的时间戳 (时间戳为23:59)

func GetNowDate

func GetNowDate() string

GetNowDate 返回当前日期的格式yyy-mm-dd

func GetNowDateTime

func GetNowDateTime() string

GetNowDateTime 返回当前日期时间的格式yyy-mm-dd hh-mm-ss

func GetNowTime

func GetNowTime() string

GetNowTime 返回当前时间的格式 hh-mm-ss

func GetZeroHourTimestamp

func GetZeroHourTimestamp() int64

GetZeroHourTimestamp 返回零时的时间戳 (时间戳为00:00)

func NewFormat

func NewFormat(t string) (*theTime, error)

NewFormat 返回指定时间字符串的unix时间戳,t应该是 "yyyy-mm-dd hh:mm:ss"

func NewISO8601

func NewISO8601(iso8601 string) (*theTime, error)

NewISO8601 返回指定的iso8601时间字符串的unix时间戳

func NewUnix

func NewUnix(unix int64) *theTime

NewUnix 返回指定时间的unix时间戳

func NewUnixNow

func NewUnixNow() *theTime

NewUnixNow 返回当前时间的unix时间戳

Types

This section is empty.

Jump to

Keyboard shortcuts

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