Print the CSV header at -n 0, refuse --separator with a record format, refuse a date field in time(), read a bare number template as a format string, and say when no data is loaded
This commit is contained in:
@@ -83,10 +83,19 @@ func timeArg(a []string) error {
|
||||
if err := layoutArity("time", 1, a); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := layoutArg(a[0])
|
||||
layout, err := layoutArg(a[0])
|
||||
if err == nil && namesADateField(layout) {
|
||||
return fmt.Errorf("time(layout): '%s' names a date field, and time draws no date; write date(from,to,layout)", layout)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// namesADateField reports a layout that prints two instants differing in their date alone apart.
|
||||
func namesADateField(layout string) bool {
|
||||
day, nextYear := time.Date(2001, 2, 3, 4, 5, 6, 0, time.UTC), time.Date(2010, 11, 12, 4, 5, 6, 0, time.UTC)
|
||||
return day.Format(layout) != nextYear.Format(layout)
|
||||
}
|
||||
|
||||
// datePrep draws a second in [from 00:00:00, to 23:59:59] UTC; the span is counted
|
||||
// in seconds, since a Duration overflows past 292 years.
|
||||
func datePrep(a []string) Call {
|
||||
|
||||
Reference in New Issue
Block a user