Companion

object Companion

Functions

Link copied to clipboard
fun formatOf(iso: String?, abbreviated: Boolean = false): String

Formats a raw ISO-8601 period as an English label, returning an empty string when unparseable. See format for localization caveats.

Link copied to clipboard
fun isSameDuration(first: String?, second: String?): Boolean

true when two ISO-8601 periods describe the same duration even if written differently ("P1Y" vs "P12M", "P1W" vs "P7D").

Link copied to clipboard

Parses an ISO-8601 duration string into a BillingPeriod.

Link copied to clipboard
fun pricePerMonthMicros(priceMicros: Long, period: String?): Long

Price in micros normalized to one average month.

Link copied to clipboard
fun pricePerWeekMicros(priceMicros: Long, period: String?): Long

Price in micros normalized to one week.

Link copied to clipboard
fun savingsPercent(baseMicros: Long, basePeriod: String?, comparedMicros: Long, comparedPeriod: String?): Int

Percentage saved by paying comparedMicros per comparedPeriod instead of baseMicros per basePeriod, normalized to a common cadence.

Link copied to clipboard

Total days for a raw ISO-8601 period, or 0 when unparseable.

Link copied to clipboard

Total months for a raw ISO-8601 period, or 0.0 when unparseable. Convenience for Java callers that only need the normalization factor.