Files
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

33 lines
1020 B
Go

package svc
import (
"strings"
libregraph "github.com/opencloud-eu/libre-graph-api-go"
)
// lessSpacesByLastModifiedDateTime reports whether the element i
// must sort before the element j.
func lessSpacesByLastModifiedDateTime(i, j *libregraph.Drive) bool {
// compare the items when both dates are set
if i.LastModifiedDateTime != nil && j.LastModifiedDateTime != nil {
return i.LastModifiedDateTime.Before(*j.LastModifiedDateTime)
}
// an item without a timestamp is considered "less than" an item with a timestamp
if i.LastModifiedDateTime == nil && j.LastModifiedDateTime != nil {
return true
}
// an item without a timestamp is considered "less than" an item with a timestamp
if i.LastModifiedDateTime != nil && j.LastModifiedDateTime == nil {
return false
}
// fallback to name if no dateTime is set on both items
return strings.ToLower(i.Name) < strings.ToLower(j.Name)
}
func reverse(less func(i, j int) bool) func(i, j int) bool {
return func(i, j int) bool {
return !less(i, j)
}
}