localtime

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: GPL-3.0 Imports: 8 Imported by: 11

Documentation

Overview

Package localtime provides time related funcs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Now

func Now() time.Time

Now returns the tuned Time with TimeSyncer.Offset().

func SetDefaultTimeSyncer

func SetDefaultTimeSyncer(syncer *TimeSyncer)

SetDefaultTimeSyncer sets the global TimeSyncer.

func Within

func Within(base, target time.Time, d time.Duration) bool

Types

type Time

type Time struct {
	time.Time
}

func New

func New(t time.Time) Time

func (Time) Bytes

func (t Time) Bytes() []byte

func (Time) Equal

func (t Time) Equal(n Time) bool

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

func (Time) Normalize

func (t Time) Normalize() Time

func (Time) RFC3339

func (t Time) RFC3339() string

func (Time) UTC

func (t Time) UTC() Time

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(b []byte) error

type TimeSyncer

type TimeSyncer struct {
	*logging.Logging
	*util.ContextDaemon

	sync.RWMutex
	// contains filtered or unexported fields
}

TimeSyncer tries to sync time to time server.

func NewTimeSyncer

func NewTimeSyncer(server string, port int, interval time.Duration) (*TimeSyncer, error)

NewTimeSyncer creates new TimeSyncer

func (*TimeSyncer) Offset

func (ts *TimeSyncer) Offset() time.Duration

Offset returns the latest time offset.

func (*TimeSyncer) Start

func (ts *TimeSyncer) Start(ctx context.Context) error

Start starts TimeSyncer

Jump to

Keyboard shortcuts

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