Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

fix csv export #3444

Merged
merged 11 commits into from
Sep 1, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.net.Uri
import arrow.core.Either
import com.ivy.base.model.TransactionType
import com.ivy.base.threading.DispatchersProvider
import com.ivy.base.time.TimeConverter
import com.ivy.data.file.FileSystem
import com.ivy.data.model.Account
import com.ivy.data.model.AccountId
Expand All @@ -23,7 +24,6 @@ import org.apache.commons.text.StringEscapeUtils
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.util.Locale
import javax.inject.Inject
Expand All @@ -34,7 +34,8 @@ class ExportCsvUseCase @Inject constructor(
private val categoryRepository: CategoryRepository,
private val transactionRepository: TransactionRepository,
private val dispatchers: DispatchersProvider,
private val fileSystem: FileSystem
private val fileSystem: FileSystem,
private val timeConverter: TimeConverter
) {

suspend fun exportToFile(
Expand Down Expand Up @@ -188,7 +189,9 @@ class ExportCsvUseCase @Inject constructor(
)

private fun Instant.csvFormat(): String {
return this.atZone(ZoneId.of("UTC")).toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
return with(timeConverter) {
[email protected]()
}.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}

private fun Double.csvFormat(): String = DecimalFormat(NUMBER_FORMAT).apply {
Expand Down
Loading