Skip to content

Commit

Permalink
reformat exporter code
Browse files Browse the repository at this point in the history
  • Loading branch information
orltom committed Jan 3, 2025
1 parent b8f9e9c commit 59d5eac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 4 additions & 4 deletions internal/export/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var _ apis.Exporter = &JSONExporter{}

type JSONExporter struct{}

func NewJSONExporter() *JSONExporter {
return &JSONExporter{}
}

func (c *JSONExporter) Write(plan []apis.Shift, writer io.Writer) error {
if plan == nil {
return errors.New("plan must not be nil")
Expand All @@ -30,7 +34,3 @@ func (c *JSONExporter) Write(plan []apis.Shift, writer io.Writer) error {

return nil
}

func NewJSONExporter() *JSONExporter {
return &JSONExporter{}
}
7 changes: 0 additions & 7 deletions internal/export/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,19 @@ func (e *TableExporter) Write(plan []apis.Shift, writer io.Writer) error {
func truncate(item reflect.Value) (string, error) {
var maxLen = 15
v := fmt.Sprintf("%v", item.Interface())
if len(v) == maxLen {
return v, nil
}

if len(v) > maxLen {
return v[:12] + "...", nil
}

return v + strings.Repeat(" ", maxLen-len(v)-1), nil
}

func formatDateOnly(item reflect.Value) (string, error) {
if item.Kind() != reflect.Struct {
return "", ErrNotDate
}

t, ok := item.Interface().(time.Time)
if !ok {
return "", ErrNotDate
}

return t.Format(time.DateOnly), nil
}

0 comments on commit 59d5eac

Please sign in to comment.