You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
538 B

  1. package storage
  2. import (
  3. "strconv"
  4. "time"
  5. )
  6. func (metadata Metadata) RemainingLimitHeaderValues() (remainingDownloads, remainingDays string) {
  7. if metadata.MaxDate.IsZero() {
  8. remainingDays = "n/a"
  9. } else {
  10. timeDifference := metadata.MaxDate.Sub(time.Now())
  11. remainingDays = strconv.Itoa(int(timeDifference.Hours()/24) + 1)
  12. }
  13. if metadata.MaxDownloads == -1 {
  14. remainingDownloads = "n/a"
  15. } else {
  16. remainingDownloads = strconv.Itoa(metadata.MaxDownloads - metadata.Downloads)
  17. }
  18. return remainingDownloads, remainingDays
  19. }