Skip to content

Commit

Permalink
datetool now shows day-of-week name
Browse files Browse the repository at this point in the history
  • Loading branch information
rickb777 committed Apr 2, 2019
1 parent 338cbdf commit 6d588f0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions datetool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func sprintf(num interface{}) string {
func title() {
if !terse && !titled {
titled = true
fmt.Printf("%-15s %-15s %-15s %s\n", "input", "number", "date", "clock")
fmt.Printf("%-15s %-15s %-15s %s\n", "-----", "------", "----", "-----")
fmt.Printf("%-15s %-15s %-15s %s\n", "input", "number", "clock", "date")
fmt.Printf("%-15s %-15s %-15s %s\n", "-----", "------", "-----", "----")
}
}

Expand All @@ -53,22 +53,22 @@ func printArg(arg string) {
title()
d := date.NewOfDays(date.PeriodOfDays(i))
c := clock.Clock(i)
fmt.Printf("%-15s %-15s %-15s %s\n", arg, sprintf(i), d, c)
fmt.Printf("%-15s %-15s %-15s %-12s %s\n", arg, sprintf(i), c, d, d.Weekday())
success = true
return
}

d, e1 := date.AutoParse(arg)
if e1 == nil {
title()
fmt.Printf("%-15s %-15s %s\n", arg, sprintf(d.DaysSinceEpoch()), d)
fmt.Printf("%-15s %-15s %15s %-12s %s\n", arg, sprintf(d.DaysSinceEpoch()), "", d, d.Weekday())
success = true
}

c, err := clock.Parse(arg)
if err == nil {
title()
fmt.Printf("%-15s %-15s %-15s %s\n", arg, sprintf(c), "", c)
fmt.Printf("%-15s %-15s %s\n", arg, sprintf(c), c)
success = true
}
}
Expand All @@ -93,7 +93,7 @@ func main() {
}

if titled {
fmt.Printf("\n# dates are counted using days since 1st Jan 1970\n")
fmt.Printf("\n# dates are counted using days since Thursday 1st Jan 1970\n")
fmt.Printf("# clock operates via milliseconds since midnight\n")
}
}

0 comments on commit 6d588f0

Please sign in to comment.