[WOOMOB-2442] Fix incremental sync missing product updates for sites with negative UTC offsets#15494
Conversation
Adds logic to convert `modified_after` timestamps from UTC to site-local time when querying products and variations. Includes utility function for adjusting time based on site timezone offset to ensure accurate API filtering.
… WooPosProductRestClient Introduces comprehensive unit tests to verify timestamp adjustment logic based on site timezone offsets, ensuring accurate handling across various edge cases.
| if (offsetHours == 0.0) return utcDateString | ||
|
|
||
| val offsetSeconds = (offsetHours * SECONDS_PER_HOUR).toInt() | ||
| val zoneOffset = ZoneOffset.ofTotalSeconds(offsetSeconds) |
There was a problem hiding this comment.
📓 We need to convert to seconds and offset seconds, since ofHours doesn't support fractional offsets like 5.5 (UTC+5:30, India).
There was a problem hiding this comment.
Pull request overview
This PR fixes WOOMOB-2442 by adjusting the modified_after timestamp used for POS incremental catalog syncs so it matches WooCommerce REST API’s comparison behavior against date_modified in the site’s local (GMT-offset) time, preventing missed updates on sites with negative UTC offsets.
Changes:
- Convert
modifiedAfter(UTC) to site-local time (via site GMT offset) before sendingmodified_afterin product and variation fetches. - Add unit tests covering negative/positive/zero/null/non-numeric offsets and date rollovers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClient.kt | Adjusts modified_after to site-local time before calling the REST API. |
| libs/fluxc-plugin/src/test/java/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClientTest.kt | Adds tests validating UTC→site-local timestamp adjustment behavior and rollovers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...lin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClient.kt
Outdated
Show resolved
Hide resolved
...lin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClient.kt
Outdated
Show resolved
Hide resolved
...org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClientTest.kt
Show resolved
Hide resolved
…n in WooPosProductRestClient Introduces a try-catch block to handle `DateTimeException` during UTC to site-local time conversion. Logs the error and falls back to the UTC string.
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/24.3 #15494 +/- ##
===============================================
Coverage 39.43% 39.44%
- Complexity 11148 11156 +8
===============================================
Files 2248 2248
Lines 129078 129091 +13
Branches 18058 18061 +3
===============================================
+ Hits 50907 50921 +14
Misses 72974 72974
+ Partials 5197 5196 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Version |
| "regular_price,sale_price,date_modified,stock_quantity,stock_status,manage_stock," + | ||
| "backordered,attributes,image,downloadable,name,type" | ||
|
|
||
| private const val SECONDS_PER_HOUR = 3600 |
There was a problem hiding this comment.
We could be using 1.hours.inWholeSeconds from std lib instead. It's a matter of taste though.
Replaces manual calculation of seconds per hour with Kotlin's `Duration` API for improved readability and consistency.

Description
Fixes WOOMOB-2442
During incremental sync, the POS sends a
modified_afterparameter to filter products changed since the last sync. The stored timestamp comes from the server's response header and is always in UTC. However, the WooCommerce REST API comparesmodified_afteragainstdate_modified, which is stored in the site's local timezone. For sites with negative UTC offsets, the UTC value is always ahead of the localdate_modified, causing recently modified products to be excluded from the sync response.This fix converts the UTC timestamp to site-local time (using
SiteModel.timezone) at the REST client level before sending themodified_afterparameter, so all callers (products, variations, catalog size check) automatically get the correction.Test Steps
Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.