From 0a733ab0f20d3a433653a8aa04be197a82a172ce Mon Sep 17 00:00:00 2001 From: akashs056 Date: Sat, 24 Aug 2024 13:26:29 +0530 Subject: [PATCH 1/3] fix: removed csvFormat() and kept UTC format --- .../main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt index 27b59c1db1..ea85ccd365 100644 --- a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt +++ b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt @@ -74,7 +74,7 @@ class ExportCsvUseCase @Inject constructor( categoriesMap: Map, ): String = csvRow { // Date - csvAppend(date?.csvFormat()) + csvAppend(date?.toString()) // Title csvAppend(title?.value) // Category @@ -100,7 +100,7 @@ class ExportCsvUseCase @Inject constructor( // Description csvAppend(description?.value) // Due Date - csvAppend(dueData?.csvFormat()) + csvAppend(dueData?.toString()) // ID csvAppend(id.value.toString()) } From f058c3baae9d2291f50ef572b4687ec0d9470ad5 Mon Sep 17 00:00:00 2001 From: akashs056 Date: Sun, 25 Aug 2024 18:39:46 +0530 Subject: [PATCH 2/3] Fix date-time formatting for CSV export --- .../com/ivy/domain/usecase/csv/ExportCsvUseCase.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt index ea85ccd365..4cea6e4635 100644 --- a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt +++ b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt @@ -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 @@ -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 @@ -74,7 +74,7 @@ class ExportCsvUseCase @Inject constructor( categoriesMap: Map, ): String = csvRow { // Date - csvAppend(date?.toString()) + csvAppend(date?.csvFormat()) // Title csvAppend(title?.value) // Category @@ -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()) } @@ -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")) + .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + } private fun Double.csvFormat(): String = DecimalFormat(NUMBER_FORMAT).apply { decimalFormatSymbols = DecimalFormatSymbols.getInstance(Locale.ENGLISH) From 06c3e3a0b9bc72f911fe1fee363bed32ebb286ca Mon Sep 17 00:00:00 2001 From: akashs056 Date: Tue, 27 Aug 2024 13:13:31 +0530 Subject: [PATCH 3/3] fix: Export timestamps in user's local time instead of UTC --- .../main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt index 4cea6e4635..494213f015 100644 --- a/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt +++ b/shared/domain/src/main/java/com/ivy/domain/usecase/csv/ExportCsvUseCase.kt @@ -188,9 +188,7 @@ class ExportCsvUseCase @Inject constructor( ) private fun Instant.csvFormat(): String { - return Instant.ofEpochMilli(this.toEpochMilli()) - .atZone(ZoneId.of("UTC")) - .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + return this.atZone(ZoneId.of("UTC")).toLocalDateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) } private fun Double.csvFormat(): String = DecimalFormat(NUMBER_FORMAT).apply {