util

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright David Thorpe 2015-2017 All Rights Reserved
Please see file LICENSE for information on distribution, etc

 Copyright David Thorpe 2015-2016 All Rights Reserved
 Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved
Please see file LICENSE for information on distribution, etc

Copyright David Thorpe 2015-2016 All Rights Reserved Please see file LICENSE for information on distribution, etc

Index

Constants

This section is empty.

Variables

View Source
var (
	Year      = regexp.MustCompile("^\\s*(\\d{4})\\s*$")            // YYYY
	YearMonth = regexp.MustCompile("^\\s*(\\d{4})-(\\d{1,2})\\s*$") // YYYY-MM
	MonthYear = regexp.MustCompile("^\\s*(\\d{1,2})-(\\d{4})\\s*$") // MM-YYYY
	NullTime  = time.Time{}
)
View Source
var (
	Empty     = regexp.MustCompile("^\\s*$")
	TimeNow   = regexp.MustCompile("^\\s*(NOW)\\s*$")
	InHours   = regexp.MustCompile("^\\s*(IN)\\s+(\\d+)\\s+(H|HR|HOUR|HRS|HOURS)\\s*$")
	InMinutes = regexp.MustCompile("^\\s*(IN)\\s+(\\d+)\\s+(M|MIN|MINUTE|MINS|MINUTES)\\s*$")
	InDays    = regexp.MustCompile("^\\s*(IN)\\s+(\\d+)\\s+(D|DAY|DAYS)\\s*$")
	YYYYMMDD  = regexp.MustCompile("^\\s*(\\d{4})-(\\d{2})-(\\d{2})\\s*$")
	ISO       = time.RFC3339Nano
)

Functions

func DeleteFileIfExists

func DeleteFileIfExists(path string) error

func ParseDatePeriod

func ParseDatePeriod(value string) (time.Time, time.Time, error)

func ParseDuration

func ParseDuration(value string, notnull bool) (time.Duration, error)

func ParseTime

func ParseTime(value string, notnull bool) (time.Time, error)

Parse english-language dates and times. Returns the time, a boolean value indicating if the time-part is significant, and an error if the time could not be parsed, or nil The 'notnull' boolean flag can be used to allow empty string, in which case time.Time{} is returned

func ResolvePath

func ResolvePath(path string, relpath string) (string, bool)

Make absolute path from a path, relative to another Returns the absolute path and a boolean value which indicates if the returned path exists or not

func UppercaseFirstLetter

func UppercaseFirstLetter(src string) string

func UserDir

func UserDir() string

Returns path to user home directory

Types

This section is empty.

Jump to

Keyboard shortcuts

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