From d16cd5e992eb79bd2ff7c477dc78eb53d6ef016a Mon Sep 17 00:00:00 2001 From: Peter Nemere Date: Wed, 13 Nov 2024 20:15:11 +1000 Subject: [PATCH] Fixing compile errors for date/time to test Sol string conversion --- api/dataimport/internal/converters/pixlem/import.go | 13 +++++++++++-- api/dataimport/sdfToRSI/util.go | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/dataimport/internal/converters/pixlem/import.go b/api/dataimport/internal/converters/pixlem/import.go index 688d500c..4d47c9e0 100644 --- a/api/dataimport/internal/converters/pixlem/import.go +++ b/api/dataimport/internal/converters/pixlem/import.go @@ -246,8 +246,7 @@ func importEMData(creatorId string, rtt string, beamLocPath string, hkPath strin product := "???" // Use current date encoded as a test sol - // A=2016, 'A' is 65 ascii - sol := fmt.Sprintf("%v%v", string(65+time.Now().Year()-2016), time.Now().YearDay()) + sol := timeToTestSol(time.Now()) ftype := "??" // PE producer := "J" @@ -303,3 +302,13 @@ func importEMData(creatorId string, rtt string, beamLocPath string, hkPath strin outData.CreatorUserId = creatorId return outData, err } + +func timeToTestSol(t time.Time) string { + // A=2016, 'A' is 65 ascii + var result string + + var asciiDate = rune('A' + t.Year() - 2016) + result += string(asciiDate) + result += strconv.Itoa(t.YearDay()) + return result +} diff --git a/api/dataimport/sdfToRSI/util.go b/api/dataimport/sdfToRSI/util.go index 1ba75c7e..b5323bcb 100644 --- a/api/dataimport/sdfToRSI/util.go +++ b/api/dataimport/sdfToRSI/util.go @@ -174,6 +174,7 @@ func readNumBetween(line string, prefix string, suffix string, readType int) (in return val, 0, lastPos, nil } +// Expected SCLK format: 2006-002T15:04:05 func makeWriteSCLInt(readSCLK string) int64 { unixSec := readTimestamp(readSCLK)