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

fix: removed csvFormat() and kept UTC format #3426

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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.convertToLocal
import com.ivy.data.file.FileSystem
import com.ivy.data.model.Account
import com.ivy.data.model.AccountId
Expand All @@ -24,6 +23,7 @@ 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 Down Expand Up @@ -74,7 +74,7 @@ class ExportCsvUseCase @Inject constructor(
categoriesMap: Map<CategoryId, Category>,
): String = csvRow {
// Date
csvAppend(date?.toString())
csvAppend(date?.csvFormat())
// Title
csvAppend(title?.value)
// Category
Expand All @@ -100,7 +100,7 @@ class ExportCsvUseCase @Inject constructor(
// Description
csvAppend(description?.value)
// Due Date
csvAppend(dueData?.toString())
csvAppend(dueData?.csvFormat())
// ID
csvAppend(id.value.toString())
}
Expand Down Expand Up @@ -187,8 +187,11 @@ class ExportCsvUseCase @Inject constructor(
id = id
)

private fun Instant.csvFormat(): String = convertToLocal()
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
private fun Instant.csvFormat(): String {
return Instant.ofEpochMilli(this.toEpochMilli())
.atZone(ZoneId.of("UTC"))
akashs056 marked this conversation as resolved.
Show resolved Hide resolved
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}

private fun Double.csvFormat(): String = DecimalFormat(NUMBER_FORMAT).apply {
decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.ENGLISH)
Expand Down
Loading