mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Fix year folder check (#472)
This commit is contained in:
parent
1cc42f0ec0
commit
716f128754
3 changed files with 72 additions and 6 deletions
|
|
@ -28,6 +28,14 @@ func NewTimeInterval(a, b time.Time) TimeRange {
|
|||
return TimeRange{a, b}
|
||||
}
|
||||
|
||||
// Year returns the time range for a given year.
|
||||
func Year(year int) TimeRange {
|
||||
return TimeRange{
|
||||
time.Date(year, time.January, 1, 0, 0, 0, 0, time.UTC),
|
||||
time.Date(year, time.December, 31, 23, 59, 59, int(time.Second-time.Nanosecond), time.UTC),
|
||||
}
|
||||
}
|
||||
|
||||
// guessDate tries to guess an RFC 3339 date time from a given string.
|
||||
func guessDate(s string) (time.Time, bool) {
|
||||
for _, layout := range []string{
|
||||
|
|
@ -100,3 +108,8 @@ func (tr *TimeRange) UnmarshalFlag(s string) error {
|
|||
func (tr TimeRange) Contains(t time.Time) bool {
|
||||
return !(t.Before(tr[0]) || t.After(tr[1]))
|
||||
}
|
||||
|
||||
// Intersects returns true if the two time ranges intersects.
|
||||
func (tr TimeRange) Intersects(other TimeRange) bool {
|
||||
return !(other[1].Before(tr[0]) || tr[1].Before(other[0]))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue