Skip to content

Commit

Permalink
Improve pricePerYear price calculation precision (#1515)
Browse files Browse the repository at this point in the history
### Description
Followup to #1504 

This slightly improves precision when calculating price per year for
weekly subscriptions.
  • Loading branch information
tonidero authored Dec 5, 2023
1 parent 27c08e2 commit f9a29c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data class Period(
private const val DAYS_PER_WEEK = 7.0
private const val DAYS_PER_MONTH = 30.0
private const val DAYS_PER_YEAR = 365.0
private const val WEEKS_PER_YEAR = 52.14
private const val WEEKS_PER_YEAR = DAYS_PER_YEAR / DAYS_PER_WEEK
private const val MONTHS_PER_YEAR = 12.0
private const val WEEKS_PER_MONTH = DAYS_PER_YEAR / MONTHS_PER_YEAR / DAYS_PER_WEEK

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class PriceExtensionsPricePerYearTest : PriceExtensionsPricePerPeriodTest() {
"$1, 1D, $365.00",
"$2, 1D, $730.00",
"$5, 15D, $121.67",
"$10, 1W, $521.40",
"$10, 2W, $260.70",
"$10, 1W, $521.43",
"$10, 2W, $260.71",
"$14.99, 1M, $179.88",
"$5, 1M, $60.00",
"$30, 2M, $180.00",
Expand Down

0 comments on commit f9a29c1

Please sign in to comment.