Fix date locale formatting for products #351
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
Checklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.ktlintin the main directory and fixed any issues.Greptile Overview
Greptile Summary
This PR fixes trial period end date formatting to respect the user's device locale instead of always using US locale. Previously,
trialPeriodEndDateStringwould always format dates in US format (e.g., "Jan 15, 2026") regardless of the device's locale settings. Now it uses the device's default locale, ensuring dates appear in the format users expect based on their regional settings.Key changes:
localizedDateFormat()utility function that usesLocale.getDefault()instead ofLocale.USRawStoreProduct.trialPeriodEndDateStringto use localized formattingStripeProductType.trialPeriodEndDateStringwhich was incorrectly usingDate.toString()(would produce a format like "Wed Jan 15 00:00:00 GMT 2026")This is a user-facing improvement that ensures proper internationalization of trial period dates displayed in paywalls.
Confidence Score: 5/5
Important Files Changed
localizedDateFormat()function to format dates using device locale instead of hardcoded US localetrialPeriodEndDateStringto uselocalizedDateFormat()for proper locale formattingtrialPeriodEndDateStringto uselocalizedDateFormat()instead ofDate.toString()Locale.getDefault()to match the new localized date formatting behaviorSequence Diagram
sequenceDiagram participant Paywall participant StoreProduct participant RawStoreProduct participant StripeProductType participant DateUtils Paywall->>StoreProduct: Access trialPeriodEndDateString StoreProduct->>RawStoreProduct: Get trialPeriodEndDateString RawStoreProduct->>RawStoreProduct: Check trialPeriodEndDate RawStoreProduct->>DateUtils: Call localizedDateFormat(MMM_dd_yyyy) DateUtils-->>RawStoreProduct: Return SimpleDateFormat with Locale.getDefault() RawStoreProduct->>RawStoreProduct: Format date RawStoreProduct-->>StoreProduct: Return formatted date string StoreProduct-->>Paywall: Return localized date (e.g., "Jan 15, 2026") Note over Paywall,DateUtils: Alternative path for Stripe products Paywall->>StripeProductType: Access trialPeriodEndDateString StripeProductType->>StripeProductType: Check trialPeriodEndDate StripeProductType->>DateUtils: Call localizedDateFormat(MMM_dd_yyyy) DateUtils-->>StripeProductType: Return SimpleDateFormat with Locale.getDefault() StripeProductType->>StripeProductType: Format date StripeProductType-->>Paywall: Return localized date string