Skip to content

Commit

Permalink
Merge pull request #8 from apphud/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ABIvan-Tech authored Mar 30, 2021
2 parents 77b8fec + b80f23d commit 53c3f92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

sdkVersion=0.8.2
sdkVersion=0.8.3
7 changes: 5 additions & 2 deletions sdk/src/main/java/com/apphud/sdk/DateTimeFormatter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import java.util.*

object DateTimeFormatter {

const val pattern = "yyyy-MM-dd'T'HH:mm:ss"
private val formatter = SimpleDateFormat(pattern, Locale.getDefault())
private const val pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

val formatter = SimpleDateFormat(pattern, Locale.getDefault()).apply {
timeZone = TimeZone.getTimeZone("UTC")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import com.apphud.sdk.domain.ApphudNonRenewingPurchase
import com.apphud.sdk.domain.ApphudSubscription
import com.apphud.sdk.domain.ApphudSubscriptionStatus
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.*

class SubscriptionMapper {

private val parser = SimpleDateFormat(DateTimeFormatter.pattern, Locale.getDefault())

private fun buildDate(date: String?): Long? = try {
date?.let { parser.parse(it)?.time }
date?.let { DateTimeFormatter.formatter.parse(it)?.time }
} catch (e: ParseException) {
null
}
Expand All @@ -28,7 +25,7 @@ class SubscriptionMapper {
productId = dto.product_id,
kind = ApphudKind.map(dto.kind),
expiresAt = expires,
startedAt = buildDate(dto.started_at),
startedAt = buildDate(dto.started_at) ?: Date().time,
cancelledAt = buildDate(dto.cancelled_at),
isInRetryBilling = dto.in_retry_billing,
isIntroductoryActivated = dto.introductory_activated,
Expand Down

0 comments on commit 53c3f92

Please sign in to comment.