Files
ccn/Services/Website/Sources/Library/Internal/Extensions/Int+Euros.swift
T

14 lines
353 B
Swift
Raw Normal View History

extension Int {
// MARK: Computed
/// The amount of euro cents as a price: whole euros bare (`€240`), anything else to the cent (`€12.50`).
var euros: String {
2026-10-25 11:55:43 +01:00
let cents = self % 100
return isMultiple(of: 100)
? "€\(self / 100)"
2026-10-25 11:55:43 +01:00
: "€\(self / 100).\(cents < 10 ? "0" : "")\(cents)"
}
}