new util shared by 3 cmd's needing location

quietlight
May 4, 2026, 8:18 PM
TUC452XHD7QYUVMZS4MA22FNCA4EDODTR4Q5JKWVXQ5KNYSHSMIAC

Dependencies

  • [2] KZKLAINJ run out of space on nest, cleaned out

Change contents

  • file addition: location.go (----------)
    [2.1]
    package utils
    import (
    "fmt"
    "strconv"
    "strings"
    )
    // ParseLocation parses a "lat,lng[,timezone]" string into its components.
    // Timezone is optional and defaults to "" (UTC).
    func ParseLocation(location string) (lat, lng float64, timezone string, err error) {
    parts := strings.Split(location, ",")
    if len(parts) < 2 || len(parts) > 3 {
    return 0, 0, "", fmt.Errorf("--location must be \"lat,lng\" or \"lat,lng,timezone\" (got %d parts)", len(parts))
    }
    lat, err = strconv.ParseFloat(strings.TrimSpace(parts[0]), 64)
    if err != nil {
    return 0, 0, "", fmt.Errorf("--location: invalid latitude: %s", parts[0])
    }
    lng, err = strconv.ParseFloat(strings.TrimSpace(parts[1]), 64)
    if err != nil {
    return 0, 0, "", fmt.Errorf("--location: invalid longitude: %s", parts[1])
    }
    if len(parts) == 3 {
    timezone = strings.TrimSpace(parts[2])
    }
    return lat, lng, timezone, nil
    }