Implemented SetIDFromDatabaseKey
This commit is contained in:
parent
398460201e
commit
526fd502be
1 changed files with 12 additions and 0 deletions
12
z/entry.go
12
z/entry.go
|
@ -2,6 +2,7 @@ package z
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
"fmt"
|
||||
"github.com/gookit/color"
|
||||
|
@ -49,6 +50,17 @@ func NewEntry(
|
|||
return newEntry, nil
|
||||
}
|
||||
|
||||
func (entry *Entry) SetIDFromDatabaseKey(key string) (error) {
|
||||
splitKey := strings.Split(key, ":")
|
||||
|
||||
if len(splitKey) < 3 || len(splitKey) > 3 {
|
||||
return errors.New("not a valid database key")
|
||||
}
|
||||
|
||||
entry.ID = splitKey[2]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (entry *Entry) SetBeginFromString(begin string) (time.Time, error) {
|
||||
var beginTime time.Time
|
||||
var err error
|
||||
|
|
Loading…
Reference in a new issue