Int+Extension.swift 582 B

123456789101112131415161718192021222324252627
  1. //
  2. // Int+Extension.swift
  3. // Gami
  4. //
  5. // Created by OneeChan on 2026/2/3.
  6. //
  7. import Foundation
  8. extension Int {
  9. var timeCountDisplay: String {
  10. if self > 3600 {
  11. String(format: "%02d:%02d:%02d", self / 3600, self % 3600 / 60, self % 60)
  12. } else {
  13. String(format: "%02d:%02d", self / 60, self % 60)
  14. }
  15. }
  16. var durationDisplay: String {
  17. "\(self)“"
  18. }
  19. func formattedAsShortNumber(fractionDigits: Int = 1) -> String {
  20. Double(self).formattedAsShortNumber(fractionDigits: fractionDigits)
  21. }
  22. }