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

Commit

Permalink
restore iso date formatting for exported files (#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvllz authored Apr 2, 2024
1 parent 196d6dd commit fd8068a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import com.ivy.domain.RootScreen
import com.ivy.frp.filterSuspend
import com.ivy.legacy.IvyWalletCtx
import com.ivy.legacy.datamodel.Account
import com.ivy.legacy.utils.formatNicelyWithTime
import com.ivy.legacy.utils.getISOFormattedDateTime
import com.ivy.legacy.utils.scopedIOThread
import com.ivy.legacy.utils.timeNowUTC
import com.ivy.legacy.utils.toLowerCaseLocal
Expand Down Expand Up @@ -450,9 +450,9 @@ class ReportViewModel @Inject constructor(
if (!filter.validate()) return

ivyContext.createNewFile(
"Report (${
timeNowUTC().formatNicelyWithTime(noWeekDay = true)
}).csv"
"IvyWalletReport-${
timeNowUTC().getISOFormattedDateTime()
}.csv"
) { fileUri ->
viewModelScope.launch {
loading.value = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.ivy.frp.monad.Res
import com.ivy.legacy.IvyWalletCtx
import com.ivy.legacy.LogoutLogic
import com.ivy.legacy.domain.action.settings.UpdateSettingsAct
import com.ivy.legacy.utils.formatNicelyWithTime
import com.ivy.legacy.utils.getISOFormattedDateTime
import com.ivy.legacy.utils.ioThread
import com.ivy.legacy.utils.timeNowUTC
import com.ivy.legacy.utils.uiThread
Expand Down Expand Up @@ -257,9 +257,9 @@ class SettingsViewModel @Inject constructor(

private fun exportToCSV(rootScreen: RootScreen) {
ivyContext.createNewFile(
"Ivy Wallet (${
timeNowUTC().formatNicelyWithTime(noWeekDay = true)
}).csv"
"IvyWalletExport_${
timeNowUTC().getISOFormattedDateTime()
}.csv"
) { fileUri ->
viewModelScope.launch {
exportCSVLogic.exportToFile(
Expand All @@ -276,9 +276,9 @@ class SettingsViewModel @Inject constructor(

private fun exportToZip(rootScreen: RootScreen) {
ivyContext.createNewFile(
"Ivy Wallet (${
timeNowUTC().formatNicelyWithTime(noWeekDay = true)
}).zip"
"IvyWalletBackup_${
timeNowUTC().getISOFormattedDateTime()
}.zip"
) { fileUri ->
viewModelScope.launch(Dispatchers.IO) {
progressState.value = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ fun LocalDateTime.formatNicely(
}
}

fun LocalDateTime.getISOFormattedDateTime(): String = this.formatLocal("yyyyMMdd-HHmm")

fun LocalDateTime.formatNicelyWithTime(
noWeekDay: Boolean = true,
zone: ZoneId = ZoneOffset.systemDefault()
Expand Down

0 comments on commit fd8068a

Please sign in to comment.