Skip to content

Commit a25f785

Browse files
authored
Merge pull request #20387 from wordpress-mobile/fix/20334-fix-timezone-issue-on-traffic-chart
Fix timezone issue on traffic chart
2 parents cb12a0f + 5c357cd commit a25f785

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/traffic/TrafficOverviewUseCase.kt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import org.wordpress.android.ui.stats.refresh.utils.trackWithGranularity
2323
import org.wordpress.android.util.AppLog
2424
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
2525
import org.wordpress.android.viewmodel.ResourceProvider
26-
import java.util.Calendar
2726
import java.util.Date
2827
import javax.inject.Inject
2928
import javax.inject.Named
@@ -110,19 +109,9 @@ class TrafficOverviewUseCase(
110109
}
111110

112111
private fun getLastDate(model: VisitsAndViewsModel?): Date? {
113-
selectedDateProvider.getSelectedDate(statsGranularity)?.let { return dateWithoutHour(it) }
114-
112+
selectedDateProvider.getSelectedDate(statsGranularity)?.let { return it }
115113
val lastDateString = model?.dates?.lastOrNull()?.period
116-
return lastDateString?.let { dateWithoutHour(statsDateFormatter.parseStatsDate(statsGranularity, it)) }
117-
}
118-
119-
// Remove the hour and minute from the date to avoid fetching incorrect dates caused by timezone differences
120-
private fun dateWithoutHour(date: Date): Date {
121-
val calendar = Calendar.getInstance()
122-
calendar.time = date
123-
calendar.set(Calendar.HOUR_OF_DAY, 0)
124-
calendar.set(Calendar.MINUTE, 0)
125-
return calendar.time
114+
return lastDateString?.let { statsDateFormatter.parseStatsDate(statsGranularity, it) }
126115
}
127116

128117
override suspend fun fetchRemoteData(forced: Boolean): State<TrafficOverviewUiModel> {
@@ -180,7 +169,8 @@ class TrafficOverviewUseCase(
180169
granularity,
181170
LimitMode.Top(quantity),
182171
date,
183-
forced
172+
forced,
173+
false
184174
)
185175
} ?: visitsAndViewsStore.fetchVisits(
186176
statsSiteProvider.siteModel,

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ext {
2525
automatticTracksVersion = '3.4.0'
2626
gutenbergMobileVersion = 'v1.114.0'
2727
wordPressAztecVersion = 'v2.0'
28-
wordPressFluxCVersion = 'trunk-8b930418a49b0d0846ed56ebf8fd8adad5011901'
28+
wordPressFluxCVersion = 'trunk-cef238b9f77fbbdc7aff16c7f1623b3d89091968'
2929
wordPressLoginVersion = '1.14.1'
3030
wordPressPersistentEditTextVersion = '1.0.2'
3131
wordPressUtilsVersion = '3.13.0'

0 commit comments

Comments
 (0)