Skip to content

Comments

POS Bookings: Fix incorrect booking time being displayed due timezone#16718

Open
iamgabrielma wants to merge 8 commits intotrunkfrom
task/WOOMOB-2575-pos-booking-timezone-fun
Open

POS Bookings: Fix incorrect booking time being displayed due timezone#16718
iamgabrielma wants to merge 8 commits intotrunkfrom
task/WOOMOB-2575-pos-booking-timezone-fun

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Feb 24, 2026

Closes WOOMOB-2575

Description

When making a test booking I've noticed that while it was made for 11AM, it showed 13PM in the app, and my timezone should fit 16PM, so the booking hours were off at some point.

It seems that the API sends local time disguised as UTC. For booking x (the 11AM Vilnius booking):

  • API raw timestamp 1771930800 decodes to 11:00 UTC
  • But 11AM Vilnius (UTC+2) should be 09:00 UTC
  • The timestamp is off by exactly +2 hours — the Vilnius GMT offset

This means the Bookings API is encoding the site-local time as a UTC timestamp, not converting to true UTC first (e.g., 11:00 AM Vilnius is sent as epoch for 11:00 UTC, not 09:00 UTC).

More details in p1771921078262749-slack-C070SJRA8DP

Changes

Created POSBookingDateFormatter that centralizes all booking time formatting using UTC, so the site-local time is shown correctly regardless of device timezone.

Test Steps

  • Create a new booking and note down the booking time. I've used https://generously-zealous-triumph.commerce-garden.com/ which is set to Vilnius time (note the store address itself is set to Ventnor City which is 12h behind, but not the booking settings)
  • In the app, switch the device timezone to something else. Then navigate to the booking. Observe that the booking day and time still matches of the original (Vilnius time)
Screenshot 2026-02-24 at 15 50 36 simulator_screenshot_306D9B26-A82F-4308-9D0F-F595B498BB93
  • Attempt to cancel booking, note the time is correct:
simulator_screenshot_507E0777-83EF-4A30-B3EC-EF58224204C8

@iamgabrielma iamgabrielma added type: bug A confirmed bug. type: task An internally driven task. feature: CIAB Mobile Experience labels Feb 24, 2026
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 24, 2026

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16718-a7d54d2
Version24.1
Bundle IDcom.automattic.alpha.woocommerce
Commita7d54d2
Installation URL7cflmf7geeqno
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma added this to the 24.2 milestone Feb 24, 2026
@iamgabrielma iamgabrielma requested a review from staskus February 24, 2026 09:10
@iamgabrielma iamgabrielma marked this pull request as ready for review February 24, 2026 09:10
…matter

The Bookings API stores site-local wall-clock times as UTC timestamps.
All booking date operations should use UTC to match this encoding.
Centralizes utcTimeZone and utcCalendar so other types can reference
them instead of creating their own. Adds formattedShortDate for the
date bar display.
The Bookings API stores local times as UTC timestamps and filters
against them in UTC. Date queries should use plain UTC midnight-to-
midnight boundaries rather than converting from the site timezone.
Removes siteTimezone from POSBookingListController and uses
POSBookingDateFormatter.utcCalendar for all date arithmetic.
Date bar now uses POSBookingDateFormatter.formattedShortDate instead of
an inline formatter with siteTimezone. Calendar view uses the shared
utcTimeZone for its DatePicker environment. Both views no longer depend
on the siteTimezone environment value.
Remove siteTimezone references and use POSBookingDateFormatter.utcCalendar.
Remove the Tokyo timezone test since timezone conversion is no longer
relevant - all booking dates use UTC.
Remove locale-dependent assertions and idempotency tests that only
verified Apple's formatter behavior. Keep one test per formatter method
that checks the output contains the correct UTC values using .contains.
Fix incorrect timestamp comments (10:00 UTC, not 9:00).
Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work, @iamgabrielma! Nice that you extracted a formatter separately.

A couple of points I found during testing and fixed right away to save some time. Please check it out and let me know if you see any problems.

Main two changes are:

  • Use UTC for date queries as well. Since times are saved in UTC, when showing dates in the date bar and making queries, we should make it in UTC as well. When we create a booking for 1AM UTC, we ignore the timezone. So when we query, we should also ignore it and just request for start-date at 00:00 UTC
  • The formatter forced a US locale. However, according to requirements the dates still need to presented for a specified region

Small changes:

  • I had to adjust tests a little bit to make sure we test only what's necessary and not Apple's formatter logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: CIAB Mobile Experience type: bug A confirmed bug. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants