Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -179,9 +179,19 @@ class ChargesViewModel @Inject constructor(
// Load the display setting
showShortDrivesCharges = settingsDataStore.showShortDrivesCharges.first()

// API expects RFC3339 format: 2006-01-02T15:04:05Z
val startDateStr = startDate?.let { "${it}T00:00:00Z" }
val endDateStr = endDate?.let { "${it}T23:59:59Z" }
// API expects RFC3339 format:
// 2006-01-02T15:04:05Z for UTC time
// 2006-01-02T15:04:05+nn:00 for local time, with nn the timezone offset
val zoneId = java.time.ZoneId.systemDefault()
val offsetFormatter = DateTimeFormatter.ofPattern("xxx") // format: +01:00
val startDateStr = startDate?.let {
val offset = zoneId.rules.getOffset(it.atStartOfDay())
"${it}T00:00:00${offset.toString()}"
}
val endDateStr = endDate?.let {
val offset = zoneId.rules.getOffset(it.atTime(23, 59, 59))
"${it}T23:59:59${offset.toString()}"
}

// Fetch charge IDs from local database aggregates
val dcChargeIds = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,19 @@ class DrivesViewModel @Inject constructor(
// Load the display setting
showShortDrivesCharges = settingsDataStore.showShortDrivesCharges.first()

// API expects RFC3339 format: 2006-01-02T15:04:05Z
val startDateStr = startDate?.let { "${it}T00:00:00Z" }
val endDateStr = endDate?.let { "${it}T23:59:59Z" }
// API expects RFC3339 format:
// 2006-01-02T15:04:05Z for UTC time
// 2006-01-02T15:04:05+nn:00 for local time, with nn the timezone offset
val zoneId = java.time.ZoneId.systemDefault()
val offsetFormatter = DateTimeFormatter.ofPattern("xxx") // format: +01:00
val startDateStr = startDate?.let {
val offset = zoneId.rules.getOffset(it.atStartOfDay())
"${it}T00:00:00${offset.toString()}"
}
val endDateStr = endDate?.let {
val offset = zoneId.rules.getOffset(it.atTime(23, 59, 59))
"${it}T23:59:59${offset.toString()}"
}

when (val result = repository.getDrives(id, startDateStr, endDateStr)) {
is ApiResult.Success -> {
Expand Down
Loading