1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-30 09:09:00 +02:00

added yesterday and tomorrow date filter macros

This commit is contained in:
Gani Georgiev
2024-12-05 13:34:11 +02:00
parent c6695b6a75
commit 7c01441392
3 changed files with 27 additions and 0 deletions

View File

@@ -23,6 +23,26 @@ var identifierMacros = map[string]func() (any, error){
return d.String(), nil
},
"@yesterday": func() (any, error) {
yesterday := timeNow().UTC().AddDate(0, 0, -1)
d, err := types.ParseDateTime(yesterday)
if err != nil {
return "", fmt.Errorf("@yesterday: %w", err)
}
return d.String(), nil
},
"@tomorrow": func() (any, error) {
tomorrow := timeNow().UTC().AddDate(0, 0, 1)
d, err := types.ParseDateTime(tomorrow)
if err != nil {
return "", fmt.Errorf("@tomorrow: %w", err)
}
return d.String(), nil
},
"@second": func() (any, error) {
return timeNow().UTC().Second(), nil
},