From e60ca67fe231474f572829ce80c610a6599a5ed9 Mon Sep 17 00:00:00 2001 From: michealroberts Date: Sun, 10 Nov 2024 15:59:53 +0000 Subject: [PATCH] fix: amend (h *FITSHeader) Set to correctly handle dates in @observerly/iris fix: amend (h *FITSHeader) Set to correctly handle dates in @observerly/iris --- pkg/fits/header.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/fits/header.go b/pkg/fits/header.go index 6c97525..8fcb1b8 100644 --- a/pkg/fits/header.go +++ b/pkg/fits/header.go @@ -142,6 +142,16 @@ func (h *FITSHeader) Set(key string, value interface{}, comment string) error { Comment: comment, } case string: + // If the string could be a date, parse it as a date: + if d, err := isDate(v); err == nil { + h.Dates[key] = FITSHeaderString{ + Value: d.Format(time.RFC3339), + Comment: comment, + } + return nil + } + + // Otherwise, simply set the string value: h.Strings[key] = FITSHeaderString{ Value: v, Comment: comment, @@ -154,19 +164,16 @@ func (h *FITSHeader) Set(key string, value interface{}, comment string) error { Value: int32(v), Comment: comment, } - case int8: h.Ints[key] = FITSHeaderInt{ Value: int32(v), Comment: comment, } - case int16: h.Ints[key] = FITSHeaderInt{ Value: int32(v), Comment: comment, } - case int32: h.Ints[key] = FITSHeaderInt{ Value: v,