From a89d78f66c16bbc1682acb9ece0db6fd3ff40a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sat, 17 Oct 2020 01:32:31 +0100 Subject: [PATCH] Implemented GetProjectIdFromName --- z/helpers.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/z/helpers.go b/z/helpers.go index 755aeba..b235bc9 100644 --- a/z/helpers.go +++ b/z/helpers.go @@ -4,6 +4,7 @@ import ( "os/user" "regexp" "strconv" + "strings" "time" "math" "errors" @@ -101,6 +102,17 @@ func ParseTime(timeStr string) (time.Time, error) { } } +func GetProjectIdFromName(projectName string) string { + reg, regerr := regexp.Compile("[^a-zA-Z0-9]+") + if regerr != nil { + return "" + } + + projectId := strings.ToLower(reg.ReplaceAllString(projectName, "")) + + return projectId +} + func GetISOCalendarWeek(date time.Time) (int) { var _, cw = date.ISOWeek() return cw