diff options
Diffstat (limited to 'time.go')
| -rw-r--r-- | time.go | 31 |
1 files changed, 13 insertions, 18 deletions
@@ -9,24 +9,23 @@ import ( ) // you will be happier if you just use this everywhere +// This is always 22 chars func Time(someTimeAgoOrLaterNotsure any) string { guess, t, err := TimeCheck(someTimeAgoOrLaterNotsure) + // this should probably be done first + if t != nil { + return FormatTime(*t) + } + if len(guess) > 0 { + return fmt.Sprintf("%-22.22s", guess) + } if errors.Is(err, Broken) { - if len(guess) > 0 { - return fmt.Sprintf("%-15s", guess) - } - return "bad" + return fmt.Sprintf("%-22.22s", "cobol.Time() Broken") } if errors.Is(err, NoTime) { - if len(guess) > 0 { - return fmt.Sprintf("%-15s", guess) - } - return "nope" + return fmt.Sprintf("%-22.22s", "cobol.Time() NoTime") } - if len(guess) > 0 { - return fmt.Sprintf("%-15s", guess) - } - return FormatTime(*t) + return fmt.Sprintf("%-22.22s", " / / : : (notsure)") } func isUTC(t time.Time) bool { @@ -50,13 +49,9 @@ func TimeLocal(someTimeAgoOrLaterNotsure any) string { return FormatTimeLocal(*t) } -func GetTime(mightBeTimeMightNotBeTime any) (time.Time, error) { +func GetTime(mightBeTimeMightNotBeTime any) (*time.Time, error) { _, t, err := TimeCheck(mightBeTimeMightNotBeTime) - if t == nil { - var emptyTime time.Time - return emptyTime, err - } - return *t, err + return t, err } func TimeCheck(maybeTime any) (string, *time.Time, error) { |
