1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-03-19 06:07:48 +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

@ -1,3 +1,8 @@
## v0.24.0 (WIP)
- Added `@yesterday` and `@tomorrow` date filter macros (@todo docs).
## v0.23.5 (WIP)
- Fixed UI logs search not properly accounting for the "Include requests by superusers" toggle when multiple search expressions are used.

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
},

View File

@ -14,6 +14,8 @@ func TestIdentifierMacros(t *testing.T) {
testMacros := map[string]any{
"@now": "2023-02-03 04:05:06.000Z",
"@yesterday": "2023-02-02 04:05:06.000Z",
"@tomorrow": "2023-02-04 04:05:06.000Z",
"@second": 6,
"@minute": 5,
"@hour": 4,