Skip to content

Commit

Permalink
Novos métodos
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-couto committed Mar 26, 2021
1 parent 0868ffd commit 61dc6bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions conversoes.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func ConvertStringDD_MM_YYYY(date string) time.Time {
return t
}

func ConverTimeToStrinLayoutYYYY_MM_DD(data time.Time) string {
data.Format(LAYOUT_YYYY_MM_DD)
return strings.Split(data.String(), " ")[0]
}

func ConvertStringToTimeLayoutYYYYMMDD(value string) time.Time {
t, _ := time.Parse(LAYOUT_YYYYMMDD, value)
return t
Expand All @@ -86,6 +91,11 @@ func ConvertStringToTimeLayoutYYYY_MM_DD(value string) time.Time {
return t
}

func ConverTimeToStrinLayoutYYYYMMDD(data time.Time) string {
data.Format(LAYOUT_YYYYMMDD)
return strings.ReplaceAll(strings.Split(data.String(), " ")[0], "-", "")
}

func ConvertStringToTimeLayoutYYMMDDHHMMSS(value string) time.Time {
t, _ := time.Parse(LAYOUT_YYMMDDHHMMSS, value)
return t
Expand Down
6 changes: 6 additions & 0 deletions string.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func RandSeq(n int) string {
return string(b)
}

func RandToken() string {
b := make([]byte, 32)
rand.Read(b)
return fmt.Sprintf("%x", b)
}

func TokenGeneratorOrderReferenceId() string {
rand.Seed(time.Now().UnixNano())
return RandSeq(16)
Expand Down

0 comments on commit 61dc6bd

Please sign in to comment.