|
- package storage
-
- import (
- "strconv"
- "time"
- )
-
- func (metadata Metadata) RemainingLimitHeaderValues() (remainingDownloads, remainingDays string) {
- if metadata.MaxDate.IsZero() {
- remainingDays = "n/a"
- } else {
- timeDifference := metadata.MaxDate.Sub(time.Now())
- remainingDays = strconv.Itoa(int(timeDifference.Hours()/24) + 1)
- }
-
- if metadata.MaxDownloads == -1 {
- remainingDownloads = "n/a"
- } else {
- remainingDownloads = strconv.Itoa(metadata.MaxDownloads - metadata.Downloads)
- }
-
- return remainingDownloads, remainingDays
- }
|