Skip to content
Snippets Groups Projects
Commit 818b498c authored by Francé Wilke's avatar Francé Wilke
Browse files

Add shared functions from Bob Go

parent a29650a0
No related branches found
No related tags found
No related merge requests found
......@@ -352,3 +352,20 @@ func TrimSpaceForPointer(s *string) *string {
func TrimAndToLower(s string) string {
return strings.ToLower(strings.TrimSpace(s))
}
func StringContainsNumbers(s string) bool {
// Define a regular expression to match numbers
regex := regexp.MustCompile("[0-9]")
// Use FindString to check if the string contains any numbers
return regex.MatchString(s)
}
func StringContainsOnlyNumbers(s string) bool {
for _, char := range s {
if !unicode.IsDigit(char) {
return false
}
}
return true
}
......@@ -3,14 +3,17 @@ package utils
import (
"bytes"
emailverifier "github.com/AfterShip/email-verifier"
"github.com/jinzhu/now"
"github.com/mohae/deepcopy"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/errors"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/string_utils"
"math"
"net/url"
"os"
"reflect"
"regexp"
"strings"
"time"
)
// GetEnv is a helper function for getting environment variables with a default
......@@ -249,3 +252,9 @@ func IsEqual(expected interface{}, actual interface{}) bool {
return reflect.DeepEqual(expected, actual)
}
func DetermineDaysLeft(fromDateLocal time.Time, toDateLocal time.Time) int {
fromDate := now.With(fromDateLocal).EndOfDay()
toDate := now.With(toDateLocal).EndOfDay()
return int(math.Floor(toDate.Sub(fromDate).Hours() / 24))
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment