Skip to content

Commit

Permalink
refactor(log): use time format constants
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Nov 8, 2023
1 parent f03fc6c commit b8f659a
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions log/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"
"os"
"strings"
"time"

"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
Expand All @@ -29,25 +30,25 @@ func (o Options) Run() error {
l.SetReportTimestamp(o.Time)

timeFormats := map[string]string{
"layout": "01/02 03:04:05PM '06 -0700",
"ansic": "Mon Jan _2 15:04:05 2006",
"unixdate": "Mon Jan _2 15:04:05 MST 2006",
"rubydate": "Mon Jan 02 15:04:05 -0700 2006",
"rfc822": "02 Jan 06 15:04 MST",
"rfc822z": "02 Jan 06 15:04 -0700",
"rfc850": "Monday, 02-Jan-06 15:04:05 MST",
"rfc1123": "Mon, 02 Jan 2006 15:04:05 MST",
"rfc1123z": "Mon, 02 Jan 2006 15:04:05 -0700",
"rfc3339": "2006-01-02T15:04:05Z07:00",
"rfc3339nano": "2006-01-02T15:04:05.999999999Z07:00",
"kitchen": "3:04PM",
"stamp": "Jan _2 15:04:05",
"stampmilli": "Jan _2 15:04:05.000",
"stampmicro": "Jan _2 15:04:05.000000",
"stampnano": "Jan _2 15:04:05.000000000",
"datetime": "2006-01-02 15:04:05",
"dateonly": "2006-01-02",
"timeonly": "15:04:05",
"layout": time.Layout,
"ansic": time.ANSIC,
"unixdate": time.UnixDate,
"rubydate": time.RubyDate,
"rfc822": time.RFC822,
"rfc822z": time.RFC822Z,
"rfc850": time.RFC850,
"rfc1123": time.RFC1123,
"rfc1123z": time.RFC1123Z,
"rfc3339": time.RFC3339,
"rfc3339nano": time.RFC3339Nano,
"kitchen": time.Kitchen,
"stamp": time.Stamp,
"stampmilli": time.StampMilli,
"stampmicro": time.StampMicro,
"stampnano": time.StampNano,
"datetime": time.DateTime,

Check failure on line 49 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.DateTime

Check failure on line 49 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.DateTime

Check failure on line 49 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.DateTime

Check failure on line 49 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.DateTime
"dateonly": time.DateOnly,

Check failure on line 50 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.DateOnly

Check failure on line 50 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.DateOnly

Check failure on line 50 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.DateOnly

Check failure on line 50 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.DateOnly
"timeonly": time.TimeOnly,

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

undefined: time.TimeOnly

Check failure on line 51 in log/command.go

View workflow job for this annotation

GitHub Actions / build (macos-latest)

undefined: time.TimeOnly
}

tf, ok := timeFormats[strings.ToLower(o.TimeFormat)]
Expand Down

0 comments on commit b8f659a

Please sign in to comment.