nptime

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package nptime provides a non-pointer version of the time.Time struct that does not have the location pointer information that time.Time has, which is more efficient from a memory management perspective, in cases where you have a lot of time values being kept: https://segment.com/blog/allocation-efficiency-in-high-performance-go-services/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Time

type Time struct {

	// time.Time.Unix() seconds since 1970
	Sec int64

	// time.Time.Nanosecond() -- nanosecond offset within second, *not* UnixNano()
	NSec uint32
}

Time represents the value of time.Time without using any pointers for the location information, so it is more memory efficient when lots of time values are being stored.

var TimeZero Time

TimeZero is the uninitialized zero time value -- use to check whether time has been set or not

func (Time) IsZero

func (t Time) IsZero() bool

IsZero returns true if the time is zero and has not been initialized

func (*Time) Now

func (t *Time) Now()

Now sets the time value to time.Now()

func (*Time) SetTime

func (t *Time) SetTime(tt time.Time)

SetTime sets the nptime.Time value based on the time.Time value

func (Time) Time

func (t Time) Time() time.Time

Time returns the time.Time value for this nptime.Time value

Jump to

Keyboard shortcuts

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