Skip to content

Commit

Permalink
Fix: #243 - converting days to years
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan authored and georgepadayatti committed Nov 28, 2023
1 parent 5bd8e7a commit 7506e8c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.github.privacyDashboard.utils.BBConsentDataUtils.EXTRA_TAG_TOKEN
import com.github.privacyDashboard.utils.BBConsentDataUtils.EXTRA_TAG_USERID
import com.github.privacyDashboard.utils.BBConsentLocaleHelper
import com.google.gson.Gson
import kotlin.math.floor


object PrivacyDashboard {
Expand Down Expand Up @@ -121,10 +122,19 @@ object PrivacyDashboard {
dataAgreement?.policy?.storageLocation
)
)
var retentionPeriod = "${dataAgreement?.policy?.dataRetentionPeriodDays.toString()} days"
try {
var years = floor(
(dataAgreement?.policy?.dataRetentionPeriodDays?.div(365)?.toDouble()
?: 0) as Double
)
retentionPeriod = "$years years"
} catch (e: Exception) {
}
subList.add(
DataAgreementPolicyModel(
context.resources.getString(R.string.bb_consent_data_agreement_policy_retention_period),
dataAgreement?.policy?.dataRetentionPeriodDays.toString()
retentionPeriod
)
)
subList.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.github.privacyDashboard.modules.dataAttribute.BBConsentDataAttributeL
import com.github.privacyDashboard.modules.webView.BBConsentWebViewActivity
import com.github.privacyDashboard.utils.BBConsentImageUtils
import com.google.gson.Gson
import kotlin.math.floor

class BBConsentDataSharingActivity : BBConsentBaseActivity() {

Expand Down Expand Up @@ -295,10 +296,19 @@ class BBConsentDataSharingActivity : BBConsentBaseActivity() {
dataAgreement?.policy?.storageLocation
)
)
var retentionPeriod = "${dataAgreement?.policy?.dataRetentionPeriodDays.toString()} days"
try {
var years = floor(
(dataAgreement?.policy?.dataRetentionPeriodDays?.div(365)?.toDouble()
?: 0) as Double
)
retentionPeriod = "$years years"
} catch (e: Exception) {
}
subList.add(
DataAgreementPolicyModel(
resources.getString(R.string.bb_consent_data_agreement_policy_retention_period),
dataAgreement?.policy?.dataRetentionPeriodDays.toString()
retentionPeriod
)
)
subList.add(
Expand Down

0 comments on commit 7506e8c

Please sign in to comment.