mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-14 07:19:52 +01:00
Implement appointment reading
This commit is contained in:
19
rechner.go
19
rechner.go
@@ -5,6 +5,8 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Sauce(malid int64, username string) string {
|
||||
@@ -24,3 +26,20 @@ func Int64ToByte(yes int64) []byte {
|
||||
n := binary.PutVarint(buf, yes)
|
||||
return buf[:n]
|
||||
}
|
||||
|
||||
func BytesToInt64AndDate(bytes []byte) (int64, time.Time, error) {
|
||||
split := strings.Split(string(bytes), AppointSplit)
|
||||
if len(split) != 2 {
|
||||
return 0, time.Time{}, fmt.Errorf("invalid appointment split %s", string(bytes))
|
||||
}
|
||||
num, err := strconv.ParseInt(split[0], 10, 64)
|
||||
if err != nil {
|
||||
return num, time.Time{}, err
|
||||
}
|
||||
appoint, err := time.Parse(time.RFC3339, split[1])
|
||||
return num, appoint, err
|
||||
}
|
||||
|
||||
func Int64AndDateToBytes(num int64, appoint time.Time) []byte {
|
||||
return []byte(fmt.Sprintf("%d%s%s", num, AppointSplit, appoint.Format(time.RFC3339)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user