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

Commit

Permalink
fix: removed csvFormat() and kept UTC format (#3426)
Browse files Browse the repository at this point in the history
* fix: removed csvFormat() and kept UTC format

* Fix date-time formatting for CSV export

* fix: Export timestamps in user's local time instead of UTC
  • Loading branch information
akashs056 authored Aug 28, 2024
1 parent cd58c0f commit 6c3937d
Showing 1 changed file with 4 additions and 3 deletions.
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 @@ -187,8 +187,9 @@ class ExportCsvUseCase @Inject constructor(
id = id
)

private fun Instant.csvFormat(): String = convertToLocal()
.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
private fun Instant.csvFormat(): String {
return this.atZone(ZoneId.of("UTC")).toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
}

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

0 comments on commit 6c3937d

Please sign in to comment.