added: time util
This commit is contained in:
parent
aeb5cb819b
commit
a338fd03b2
2 changed files with 16 additions and 1 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
import "github.com/gin-gonic/gin"
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Utils interface {
|
type Utils interface {
|
||||||
IsEmail(email string) bool
|
IsEmail(email string) bool
|
||||||
|
|
@ -8,4 +11,5 @@ type Utils interface {
|
||||||
GetRefreshUuidFromContext(c *gin.Context) (string, error)
|
GetRefreshUuidFromContext(c *gin.Context) (string, error)
|
||||||
HashPassword(password string) (string, error)
|
HashPassword(password string) (string, error)
|
||||||
ComparePasswords(hashedPassword string, plainPassword string) error
|
ComparePasswords(hashedPassword string, plainPassword string) error
|
||||||
|
ParseTime(t string) (time.Time, error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
pkg/utils/time.go
Normal file
11
pkg/utils/time.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package utils
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (u *Utils) ParseTime(t string) (time.Time, error) {
|
||||||
|
timeStr, err := time.Parse(time.RFC3339, t)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
return timeStr, nil
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue