mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-19 22:19:23 +02:00
added yesterday and tomorrow date filter macros
This commit is contained in:
parent
c6695b6a75
commit
7c01441392
@ -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.
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user