Files
2026-08-06 18:26:45 +12:00

19 lines
408 B
Go

package handlers
import "time"
const dateLayout = "2006-01-02"
// parseOptionalDate parses a "YYYY-MM-DD" string, treating nil/empty as no
// value. Used for the optional date fields on car/reminder inputs.
func parseOptionalDate(s *string) (*time.Time, error) {
if s == nil || *s == "" {
return nil, nil
}
t, err := time.Parse(dateLayout, *s)
if err != nil {
return nil, err
}
return &t, nil
}