[PR #1616] [MERGED] add date and time formatting methods to localize service #96386

Closed
opened 2026-05-30 19:48:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1616
Author: @jlf0dev
Created: 10/28/2021
Status: Merged
Merged: 10/28/2021
Merged by: @jlf0dev

Base: masterHead: bug/date-locale-format


📝 Commits (1)

  • cc3bcfa add date and time formatting methods to localize service

📊 Changes

9 files changed (+72 additions, -11 deletions)

View changed files

📝 src/Android/Services/LocalizeService.cs (+10 -0)
📝 src/App/Abstractions/ILocalizeService.cs (+14 -1)
📝 src/App/Pages/Send/SendsPage.xaml (+0 -1)
📝 src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs (+5 -2)
📝 src/App/Pages/Settings/SyncPageViewModel.cs (+5 -1)
📝 src/App/Pages/Vault/CiphersPage.xaml (+0 -1)
📝 src/App/Pages/Vault/ViewPageViewModel.cs (+6 -4)
📝 src/App/Utilities/DateTimeConverter.cs (+12 -1)
📝 src/iOS.Core/Services/LocalizeService.cs (+20 -0)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Apple supports many language-locale combinations that .Net is lacking. If a user is "en-FR" for example, we default that to "en" to set the CultureInfo object used in localization.

Date formatting in .Net uses this CultureInfo object to decide how to show dates and times. Since we default unsupported locales to just "en", users noticed dates didn't appear in their chosen region format.

This change introduces date and time formatting methods to LocalizationService so we can use Apple APIs instead of the .Net ones relying on CultureInfo. Android formatting will still use the .Net ones.

Closes bitwarden/desktop#640

Asana Task: https://app.asana.com/0/1169444489336079/1199535628242243/f

Code changes

  • src/App/Abstractions/ILocalizeService.cs: Added date and time formatting methods
  • src/Android/Services/LocalizeService.cs: Implemented date and time formatting using .Net
  • src/iOS.Core/Services/LocalizeService.cs: Implemented date and time formatting using Apple APIs
  • SettingsPageViewModel.cs: Added date and time formatting using LocalizeService
  • SyncPageViewModel.cs: Added date and time formatting using LocalizeService
  • ViewPageViewModel.cs: Added date and time formatting using LocalizeService
  • DateTimeConverter.cs: Added date and time formatting using LocalizeService
  • SendsPage.xaml: Removed unnecessary call to DateTimeConverter
  • CiphersPage.xaml: Removed unnecessary call to DateTimeConverter

Screenshots

iPhone set to en-fr, unsupported in .Net
Screen Shot 2021-10-28 at 10 43 40 AM

Bitwarden still formats correctly
Screen Shot 2021-10-28 at 10 45 34 AM

Testing requirements

  • iOS testing of unsupported language-locale in .Net, examples are en-fr, en-es, fr-ir
  • Regression testing to ensure current behavior still works

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1616 **Author:** [@jlf0dev](https://github.com/jlf0dev) **Created:** 10/28/2021 **Status:** ✅ Merged **Merged:** 10/28/2021 **Merged by:** [@jlf0dev](https://github.com/jlf0dev) **Base:** `master` ← **Head:** `bug/date-locale-format` --- ### 📝 Commits (1) - [`cc3bcfa`](https://github.com/bitwarden/android/commit/cc3bcfa73fa157387c31247b8121f0f36787bf0f) add date and time formatting methods to localize service ### 📊 Changes **9 files changed** (+72 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/Android/Services/LocalizeService.cs` (+10 -0) 📝 `src/App/Abstractions/ILocalizeService.cs` (+14 -1) 📝 `src/App/Pages/Send/SendsPage.xaml` (+0 -1) 📝 `src/App/Pages/Settings/SettingsPage/SettingsPageViewModel.cs` (+5 -2) 📝 `src/App/Pages/Settings/SyncPageViewModel.cs` (+5 -1) 📝 `src/App/Pages/Vault/CiphersPage.xaml` (+0 -1) 📝 `src/App/Pages/Vault/ViewPageViewModel.cs` (+6 -4) 📝 `src/App/Utilities/DateTimeConverter.cs` (+12 -1) 📝 `src/iOS.Core/Services/LocalizeService.cs` (+20 -0) </details> ### 📄 Description ## Type of change - [x] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Apple supports many language-locale combinations that .Net is lacking. If a user is "en-FR" for example, we default that to "en" to set the `CultureInfo` object used in localization. Date formatting in .Net uses this `CultureInfo` object to decide how to show dates and times. Since we default unsupported locales to just "en", users noticed dates didn't appear in their chosen region format. This change introduces date and time formatting methods to `LocalizationService` so we can use Apple APIs instead of the .Net ones relying on `CultureInfo`. Android formatting will still use the .Net ones. Closes bitwarden/desktop#640 Asana Task: https://app.asana.com/0/1169444489336079/1199535628242243/f ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **src/App/Abstractions/ILocalizeService.cs:** Added date and time formatting methods * **src/Android/Services/LocalizeService.cs:** Implemented date and time formatting using .Net * **src/iOS.Core/Services/LocalizeService.cs:** Implemented date and time formatting using Apple APIs * **SettingsPageViewModel.cs:** Added date and time formatting using LocalizeService * **SyncPageViewModel.cs:** Added date and time formatting using LocalizeService * **ViewPageViewModel.cs:** Added date and time formatting using LocalizeService * **DateTimeConverter.cs:** Added date and time formatting using LocalizeService * **SendsPage.xaml:** Removed unnecessary call to DateTimeConverter * **CiphersPage.xaml:** Removed unnecessary call to DateTimeConverter ## Screenshots <!--Required for any UI changes. Delete if not applicable--> iPhone set to en-fr, unsupported in .Net ![Screen Shot 2021-10-28 at 10 43 40 AM](https://user-images.githubusercontent.com/24985544/139280226-3e4de3ae-dc62-4eb6-b5e6-15c58a32663b.png) Bitwarden still formats correctly ![Screen Shot 2021-10-28 at 10 45 34 AM](https://user-images.githubusercontent.com/24985544/139280290-037cc68e-4b71-44be-8002-2dfefa6695c8.png) ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> - iOS testing of unsupported language-locale in .Net, examples are en-fr, en-es, fr-ir - Regression testing to ensure current behavior still works ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-30 19:48:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#96386