feat: add expiration time in the note web view
All checks were successful
/ pre-commit (push) Successful in 1m7s
All checks were successful
/ pre-commit (push) Successful in 1m7s
Fixes #35. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
2c3ca08dbf
commit
634326190c
3 changed files with 17 additions and 1 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ReadConfig(file string, config interface{}) error {
|
||||
|
@ -102,6 +103,15 @@ func HumanDuration(i int) string {
|
|||
return fmt.Sprintf("%d %s", i, w)
|
||||
}
|
||||
|
||||
// TimeDiff to return the number of seconds between this time and now
|
||||
func TimeDiff(ts time.Time) int {
|
||||
diff := int(time.Since(ts).Seconds())
|
||||
if diff < 0 {
|
||||
return diff * -1
|
||||
}
|
||||
return diff
|
||||
}
|
||||
|
||||
func ReturnError(logger *slog.Logger, message string, err error) int {
|
||||
if err != nil {
|
||||
logger.Error(message, slog.Any("error", err))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue