package timeutil

import "github.com/teamwork/utils/timeutil"

Index

Functions

func DaysBetween

func DaysBetween(fromDate, toDate time.Time) int

DaysBetween return the number of whole days between a start date and end date

func EndOfMonth

func EndOfMonth(date time.Time) time.Time

EndOfMonth returns the last day of the month of date.

func FormatAsZulu

func FormatAsZulu(t time.Time) string

FormatAsZulu gets a ISO 8601 formatted date. The date is assumed to be in UTC ("Zulu time").

TODO: I think we can just use t.Format(time.RFC3339)?

func MonthsTo

func MonthsTo(a time.Time) int

MonthsTo returns the number of months from the current date to the given date. The number of months is always rounded down, with a minimal value of 1.

For example this returns 2:

MonthsTo(time.Now().Add(24 * time.Hour * 70))

Dates in the past are not supported, and their behaviour is undefined!

func StartOfMonth

func StartOfMonth(date time.Time) time.Time

StartOfMonth returns the first day of the month of date.

func UnixMilli

func UnixMilli() int64

UnixMilli returns the number of milliseconds elapsed since January 1, 1970 UTC.

Source Files

timeutil.go

Version
v1.0.0 (latest)
Published
Mar 14, 2022
Platform
js/wasm
Imports
1 packages
Last checked
20 hours ago

Tools for package owners.