util

package
v0.0.0-...-a2a2cd2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT, MIT Imports: 6 Imported by: 1

Documentation

Overview

The util package contains general functions to support the other packages (timeutils, sysutils)

Index

Constants

View Source
const (
	// Default time format
	TIMEFORMAT = "2006-01-02 15:04:05 MST"

	// Default time format
	TIMEFORMAT_NO_TZ = "2006-01-02 15:04:05"

	// Time format used by the Google Drive api
	DRIVE_TIMEFORMAT = "2006-01-02T15:04:05.000Z"

	// Timezone for Dexcom interval time values
	INTERNAL_TIMEZONE = "GMT"

	// Let's make days end at 18h00
	HOUR_OF_END_OF_DAY = 18
)

Variables

View Source
var GLUKIT_EPOCH_TIME = time.Unix(1072915200, 0)

Beginning of time should be unix epoch 0 but, to optimize some processing may iterate overtime starting at this value, we just define the notion of Glukit epoch time and have this value be set to something less far back but still before anything interesting happened in the Glukit world. This maps to 01 Jan 2004 00:00:00 GMT.

Functions

func GetEndOfDayBoundaryBefore

func GetEndOfDayBoundaryBefore(timeValue time.Time) (latestEndOfDayBoundary time.Time)

GetEndOfDayBoundaryBefore returns the boundary of very last "end of day" before the given time. To give an example, if the given time is July 17th 8h00 PST, the boundary returned is going to be July 17th 06h00. If the time is July 17th 05h00 PST, the boundary returned is July 16th 06h00. Very important: The timeValue's location must be accurate!

func GetLocalTimeInProperLocation

func GetLocalTimeInProperLocation(localTime string, internalTime time.Time) (localTimeWithLocation time.Time)

GetLocalTimeInProperLocation returns the parsed local time with the location appropriately set as extrapolated by calculating the difference of the internal time vs the local time

func GetLocaltimeOffset

func GetLocaltimeOffset(localTime string, internalTime time.Time) (location *time.Location)

GetLocaltimeOffset returns the Fixed location extrapolated by calculating the offset of the localtime and the internal time in UTC

func GetMidnightUTCBefore

func GetMidnightUTCBefore(timeValue time.Time) (latestMidnightBoundary time.Time)

GetMidnightUTCBefore returns the boundary of very last occurence of midnight before the given time. To give an example, if the given time is July 17th 2h00 UTC, the boundary returned is going to be July 17th 00h00. If the time is July 16th 23h00 PST, the boundary returned is July 16th 00h00.

func GetOrLoadLocationForName

func GetOrLoadLocationForName(locationName string) (location *time.Location, err error)

func GetTimeInSeconds

func GetTimeInSeconds(timeValue string) (value int64)

GetTimeInSeconds parses a datetime string and returns its unix timestamp.

func GetTimeUTC

func GetTimeUTC(timeValue string) (time.Time, error)

GetTimeInSeconds parses a datetime string and returns its unix timestamp.

func GetTimeWithImpliedLocation

func GetTimeWithImpliedLocation(localTime string, location *time.Location) (time.Time, error)

func ParseGoogleDriveDate

func ParseGoogleDriveDate(value string) (timeValue time.Time, err error)

ParseGoogleDriveDate parses a Google Drive API time value

func Propagate

func Propagate(err error)

Propagate aborts the current execution if err is non-nil.

func TimeInUTCNoTz

func TimeInUTCNoTz(timevalue time.Time) (localTime string)

Returns the timevalue with its timezone set to UTC but without printing the timezone in the formatted string

Types

This section is empty.

Jump to

Keyboard shortcuts

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