| 523 | } |
| 524 | |
| 525 | func createSnapshotTimeFilter(timespec string) (func(*snapshot.Manifest, int, int) bool, error) { |
| 526 | if timespec == "" || timespec == "latest" { |
| 527 | return func(_ *snapshot.Manifest, i, _ int) bool { |
| 528 | return i == 0 |
| 529 | }, nil |
| 530 | } |
| 531 | |
| 532 | if timespec == "oldest" { |
| 533 | return func(_ *snapshot.Manifest, i, total int) bool { |
| 534 | return i == total-1 |
| 535 | }, nil |
| 536 | } |
| 537 | |
| 538 | t, err := computeMaxTime(timespec) |
| 539 | if err != nil { |
| 540 | return nil, err |
| 541 | } |
| 542 | |
| 543 | return func(m *snapshot.Manifest, _, _ int) bool { |
| 544 | return m.StartTime.ToTime().Before(t) |
| 545 | }, nil |
| 546 | } |
| 547 | |
| 548 | var timeAgoRE = regexp.MustCompile(`^(?:(\d{1,3})(?:y|year|years)-)?(?:(\d{1,3})(?:m|mo|month|months)-)?(?:(\d{1,3})(?:d|day|days)-)?ago$`) |
| 549 | |