aboutsummaryrefslogtreecommitdiff
path: root/exp/functions.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 17:35:03 +0200
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 17:35:03 +0200
commiteaf9fa51cdd9509c5d075633b712ec9b5ea712c7 (patch)
tree90e5845ef70b9db272f202aedcbd5b5e024b4623 /exp/functions.go
parent067e149e72da10790e347b82045d82a96397d6cf (diff)
perf(db): remove useless XP data
Diffstat (limited to 'exp/functions.go')
-rw-r--r--exp/functions.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/exp/functions.go b/exp/functions.go
index 2cbe7bf..720a755 100644
--- a/exp/functions.go
+++ b/exp/functions.go
@@ -1,8 +1,11 @@
package exp
import (
+ "fmt"
+ "github.com/anhgelus/gokord"
"math"
"slices"
+ "time"
)
func MessageXP(length uint, diversity uint) uint {
@@ -42,3 +45,15 @@ func LevelXP(level uint) uint {
math.Pow(float64(5*level), 2),
))
}
+
+// TimeStampNDaysBefore returns the timestamp (year-month-day) n days before today
+func TimeStampNDaysBefore(n uint) string {
+ var y, d int
+ var m time.Month
+ if gokord.Debug {
+ y, m, d = time.Unix(time.Now().Unix()-int64(24*60*60), 0).Date() // reduce time for debug
+ } else {
+ y, m, d = time.Unix(time.Now().Unix()-int64(n*24*60*60), 0).Date()
+ }
+ return fmt.Sprintf("%d-%d-%d", y, m, d)
+}