util

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCSVMessage added in v0.0.3

func FormatCSVMessage(ctx *context.Configuration, punches []*model.PunchResponse) ([]byte, error)

FormatCSVMessage returns a slice of bytes and an error based on a valid context and a pointer to a punch query response entity. It converts the punches query into a valid format that will be converted into a report used for automatic validation.

func GetDefaultMessage

func GetDefaultMessage(ctx *context.Configuration, message string, datetime time.Time) string

GetDefaultMessage returns a valid string message. If message provided is empty it will check the datetime and return an adequate WorkStart or WorkEnd message.

func GetPassword

func GetPassword() ([]byte, error)

GetPassword reads a password from stdin

func IsHoliday

func IsHoliday(date time.Time) bool

IsHoliday reports whether date is a holiday as provided in the config file.

func IsRegularDay

func IsRegularDay(date time.Time) bool

IsRegularDay reports whether date is NOT a holiday as provided by the config file and is also a weekday neither saturday nor sunday.

func IsSameDay

func IsSameDay(day1, day2 time.Time) bool

IsSameDay reports whether day1 and day2 have same day, month and year. It does not check for hours, minutes and seconds.

func IsSaturday

func IsSaturday(date time.Time) bool

IsSaturday reports whether date is a saturday

func IsSunday

func IsSunday(date time.Time) bool

IsSunday reports whether date is a saturday

func IsWeekHoliday

func IsWeekHoliday(date time.Time) bool

IsWeekHoliday reports whether date is a holiday as provided by the config file and is also a weekday neither saturday nor sunday.

func IsWeekday

func IsWeekday(date time.Time) bool

IsWeekday reports whether date is a valid weekday neither saturday nor sunday.

func ParseFlagDate

func ParseFlagDate(date string) (time.Time, error)

ParseFlagDate returns a Time and an error. It will attempt to parse the date given that it is in a valid format ('d-m-yy') and return it as a time.Time format.

func ParseFlagDatetime

func ParseFlagDatetime(date, hour string) (time.Time, error)

ParseFlagDatetime returns a Time and an error. It will attempt to parse the date and hour given that they are both in valid formats (date: 'd-m-yy', hour: 'HH:mm') and return it as a time.Time format.

func PrintUsage

func PrintUsage()

PrintUsage is responsible for printing a valid doc message based upon the command provided. When invalid command default message will be provided.

func RangeBetweenDatesInDays

func RangeBetweenDatesInDays(start, end string) (time.Time, time.Time, int, error)

RangeBetweenDatesInDays returns start and end as time.Time formats an int representing the range size in days and an error. It will attempt to parse start and end date given that they are in a valid format ('d-m-yy') to time.Time format and calculate the range in days between them.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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