etime

package module
v0.0.0-...-c9ff777 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

etime

Encapsulate golang time operations, time operations are easier

Installation

GO111MODULE=on
go get github.com/dkys/etime

Using

package main

import (
	"fmt"
	"github.com/dkys/etime"
)

func main() {
	start, end := etime.Today()
	timeStr := etime.Format(start, "Y-m-d H/i/s")
	fmt.Printf("start %v\n end %v\n timeStr %s\n", start, end, timeStr)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DayAgoOrAfter

func DayAgoOrAfter(n int) (start, end time.Time)

DayAgoOrAfter 以当天为准 获取 几天前或者几天后的 开始和结束时间

func DayFirst

func DayFirst(d time.Time) time.Time

DayFirst 获取某个时间的0点

func DayLast

func DayLast(d time.Time) time.Time

DayLast 获取某个时间的结束时间

func DayOfAgoOrAfter

func DayOfAgoOrAfter(d time.Time, n int) (start, end time.Time)

DayOfAgoOrAfter 以某天为准 获取 几天前或者几天后的 开始和结束时间

func Format

func Format(d time.Time, spec ...string) string

Format Returns a date string of a specific format e.g. Format(t ,"Y/m/d H:i:s")

func Month

func Month() (time.Time, time.Time)

Month 获取当月的开始和结束时间戳

func MonthByNum

func MonthByNum(n int) (time.Time, time.Time)

MonthByNum 获取月份的开始和结束时间 e.g. 想要获取3月份的开始和结束时间 MonthByNumber(3)

func MonthFirst

func MonthFirst(t time.Time) time.Time

MonthFirst 获取某个时间所在月份的第一天

func MonthFirstByNum

func MonthFirstByNum(n int) time.Time

func MonthLast

func MonthLast(t time.Time) time.Time

MonthLast 获取某个时间所在月份的最后一天

func MonthLastByNum

func MonthLastByNum(n int) time.Time

func ParseSpec

func ParseSpec(spec string) string

func Str2Time

func Str2Time(date string, spec ...string) time.Time

Str2Time 返回 日期字符串=>时间对象 e.g. Str2Time('2021-01-03 23/45/46' ,"Y/m/d H:i:s")

func TimeOfDay

func TimeOfDay(d time.Time) (start, end time.Time)

TimeOfDay 获取某天的开始和结束时间

func Today

func Today() (start, end time.Time)

Today 获取当天的开始和结束时间戳

func Week

func Week() (time.Time, time.Time)

Week 获取当天的开始和结束时间戳

func WeekFirst

func WeekFirst(t time.Time) time.Time

WeekFirst 获取某个时间所在周的第一天

func Weekend

func Weekend(t time.Time) time.Time

Weekend 获取某个时间所在周的周末

func Yesterday

func Yesterday() (start, end time.Time)

Yesterday 获取昨天的开始和结束时间戳

Types

This section is empty.

Jump to

Keyboard shortcuts

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