summaryrefslogtreecommitdiffstats
path: root/vendor/go.mau.fi/whatsmeow/binary/attrs.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.mau.fi/whatsmeow/binary/attrs.go')
-rw-r--r--vendor/go.mau.fi/whatsmeow/binary/attrs.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/go.mau.fi/whatsmeow/binary/attrs.go b/vendor/go.mau.fi/whatsmeow/binary/attrs.go
index 35acd396..d7d43f0a 100644
--- a/vendor/go.mau.fi/whatsmeow/binary/attrs.go
+++ b/vendor/go.mau.fi/whatsmeow/binary/attrs.go
@@ -9,6 +9,7 @@ package binary
import (
"fmt"
"strconv"
+ "time"
"go.mau.fi/whatsmeow/types"
)
@@ -112,6 +113,16 @@ func (au *AttrUtility) GetBool(key string, require bool) (bool, bool) {
}
}
+func (au *AttrUtility) GetUnixTime(key string, require bool) (time.Time, bool) {
+ if intVal, ok := au.GetInt64(key, require); !ok {
+ return time.Time{}, false
+ } else if intVal == 0 {
+ return time.Time{}, true
+ } else {
+ return time.Unix(intVal, 0), true
+ }
+}
+
// OptionalString returns the string under the given key.
func (au *AttrUtility) OptionalString(key string) string {
strVal, _ := au.GetString(key, false)
@@ -155,6 +166,16 @@ func (au *AttrUtility) Bool(key string) bool {
return val
}
+func (au *AttrUtility) OptionalUnixTime(key string) time.Time {
+ val, _ := au.GetUnixTime(key, false)
+ return val
+}
+
+func (au *AttrUtility) UnixTime(key string) time.Time {
+ val, _ := au.GetUnixTime(key, true)
+ return val
+}
+
// OK returns true if there are no errors.
func (au *AttrUtility) OK() bool {
return len(au.Errors) == 0