Skip to content

Detect users browser locale for time format 12/24 hours#1900

Merged
PeerRich merged 40 commits intomainfrom
fix/1378-detect-browser-time-locale
Feb 23, 2022
Merged

Detect users browser locale for time format 12/24 hours#1900
PeerRich merged 40 commits intomainfrom
fix/1378-detect-browser-time-locale

Conversation

@agustif
Copy link
Copy Markdown
Contributor

@agustif agustif commented Feb 17, 2022

What does this PR do?

This PR introduces a new util timeFormat -> renamed to detectBrowserTimeFormat to detect the browser locale of the user and format the dates accordingly.

I need to integrate it everywhere, started on BookingPage.
We respect the current implementation that lets the user switch the am/pm settings, but aut-detect it's browser locale to set it by default in the booking page and rest of the site (where is not configurable)

Fixes #1378

In places like payment page, sucess, meeting ended, etc I've left the new browserLocale instead of using useState (since it wasn't using the clock is24h util either on those pages)

Let me know what do you think and if I missed any time I need to fix please!

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

Go to create a new booking, select a date and a time. Make sure the time is in the format of your browser locale. If you set 'en-US' as your default in chrome, you should see it with am/pm attached. 'es-ES' should show a 24h format without it.

You can test by reordering your top-language in chrome settings. Remember to delete the localStorage timeOptions.is24hClock setting so it takes the browser defaults instead

  • Test 'en-US' === '01:00pm'
  • Test 'es-ES' === '13:00'

Video of testing the Switch and deletion of localStorage

https://www.loom.com/share/7ca400a8cf1e438b9841b3eac98c39b7

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code and corrected any misspellings
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@agustif agustif self-assigned this Feb 17, 2022
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 17, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

docs – ./apps/docs

🔍 Inspect: https://vercel.com/cal/docs/D7drTzAj4CWhtCqQQTRwwDfZjo46
✅ Preview: https://docs-git-fix-1378-detect-browser-time-locale-cal.vercel.app

[Deployment for d5fb4d3 canceled]

calendso – ./apps/web

🔍 Inspect: https://vercel.com/cal/calendso/BuibiHxra2J51ZKSvDu3j2RDmfRR
✅ Preview: https://calendso-git-fix-1378-detect-browser-time-locale-cal.vercel.app

@agustif agustif changed the title Draft: adds new isBrowserLocal24h timeFormat util, uses in BookingPage Draft: Detect users browser locale for time format 12/24 hours Feb 17, 2022
@vercel vercel bot temporarily deployed to Preview – docs February 17, 2022 23:33 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 17, 2022 23:33 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 17, 2022 23:37 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 17, 2022 23:37 Inactive
@PeerRich
Copy link
Copy Markdown
Member

what's missing @agustif ?

@agustif
Copy link
Copy Markdown
Contributor Author

agustif commented Feb 19, 2022

what's missing @agustif ?

Need to revert back removal of is24h switch and make it detect browser locale.

Will finish it up today. =)

…tions, renames timeFormat to detectBrowserTimeFormat to avoid collisions
@vercel vercel bot temporarily deployed to Preview – docs February 19, 2022 21:26 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 19, 2022 21:26 Inactive
…f, by calling it only if no localStorage settings are set
@vercel vercel bot temporarily deployed to Preview – calendso February 19, 2022 23:49 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 19, 2022 23:49 Inactive
@agustif agustif marked this pull request as draft February 19, 2022 23:53
@vercel vercel bot temporarily deployed to Preview – docs February 19, 2022 23:56 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 19, 2022 23:56 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 19, 2022 23:56 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 21, 2022 16:54 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 21, 2022 18:47 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 21, 2022 18:47 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 21, 2022 19:10 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 21, 2022 19:10 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 21, 2022 20:11 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 21, 2022 20:11 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 22, 2022 12:34 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 22, 2022 12:34 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 22, 2022 19:06 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 22, 2022 19:06 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 22, 2022 20:17 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 22, 2022 20:17 Inactive
@vercel vercel bot temporarily deployed to Preview – docs February 22, 2022 21:25 Inactive
@vercel vercel bot temporarily deployed to Preview – calendso February 22, 2022 21:25 Inactive
Copy link
Copy Markdown
Contributor

@pumfleet pumfleet left a comment

Choose a reason for hiding this comment

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

Nice :) looks good

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

Labels

♻️ autoupdate tells kodiak to keep this branch up-to-date ✨ feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect timezone and choose am/pm or 24h per event type

4 participants