Initial import

This commit is contained in:
2026-02-14 15:59:31 +01:00
parent 05dcea3c2b
commit f1ecbfaf8d
19 changed files with 2675 additions and 0 deletions

33
protocol/aprs/time.go Normal file
View File

@@ -0,0 +1,33 @@
package aprs
import (
"fmt"
"time"
)
type TimeFormatError struct {
Time string
}
func (err TimeFormatError) Error() string {
return fmt.Sprintf("aprs: unknown time stamp %q", err.Time)
}
func ParseTime(s string) (time.Time, error) {
if len(s) < 7 {
return time.Time{}, TimeFormatError{s}
}
switch {
case s[6] == 'z': // Day/Hours/Minutes (DHM) format
return time.Parse("021504", s[:6])
case s[6] == '/': // Day/Hours/Minutes (DHM) format
return time.Parse("021504", s[:6])
case s[6] == 'h': // Hours/Minutes/Seconds (HMS) format
return time.Parse("150405", s[:6])
case len(s) >= 8: // Month/Day/Hours/Minutes (MDHM) format
return time.Parse("01021504", s[:8])
default:
return time.Time{}, TimeFormatError{s}
}
}