parseTimeFlagSec parses a time flag that can be absolute (ISO 8601, timestamp) or relative (+/- Nd/w/m/h). It returns the Unix seconds string.
(input string, hint string)
| 172 | // parseTimeFlagSec parses a time flag that can be absolute (ISO 8601, timestamp) or relative (+/- Nd/w/m/h). |
| 173 | // It returns the Unix seconds string. |
| 174 | func parseTimeFlagSec(input string, hint string) (string, error) { |
| 175 | if isRelativeTime(input) { |
| 176 | t, err := parseRelativeTime(input) |
| 177 | if err != nil { |
| 178 | return "", err |
| 179 | } |
| 180 | // Snap to day if unit is days or weeks |
| 181 | if strings.HasSuffix(input, "d") || strings.HasSuffix(input, "w") { |
| 182 | if hint == "end" { |
| 183 | t = time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, t.Location()) |
| 184 | } else { |
| 185 | t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) |
| 186 | } |
| 187 | } |
| 188 | return fmt.Sprintf("%d", t.Unix()), nil |
| 189 | } |
| 190 | return common.ParseTime(input, hint) |
| 191 | } |
no test coverage detected