Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utilities/date-time-format): prevent "0 years" display #18322

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

janhassel
Copy link
Member

Since we define months as four-week periods instead of calendar months, the current implementation of relative date and time format can result in "0 years ago" displays. This code fixes it according to the guidelines.

Changelog

Changed

  • Use "months" preset if 364 days or less.
  • Updated test to catch this

Testing / Reviewing

The updated automated test would fail with the previous implementation as it would result in "0 years ago" instead of "12 months ago"

@janhassel janhassel requested a review from a team as a code owner January 10, 2025 09:56
@janhassel janhassel requested review from kennylam and guidari January 10, 2025 09:56
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for v11-carbon-web-components ready!

Name Link
🔨 Latest commit ca22694
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-web-components/deploys/679a3ba69d907e0008f3760c
😎 Deploy Preview https://deploy-preview-18322--v11-carbon-web-components.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit ca22694
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/679a3ba674e6ed0008b7ae81
😎 Deploy Preview https://deploy-preview-18322--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ca22694
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/679a3ba6077e1100080c6a34
😎 Deploy Preview https://deploy-preview-18322--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.16%. Comparing base (051cedd) to head (ca22694).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18322   +/-   ##
=======================================
  Coverage   84.16%   84.16%           
=======================================
  Files         408      408           
  Lines       14449    14449           
  Branches     4696     4646   -50     
=======================================
  Hits        12161    12161           
  Misses       2124     2124           
  Partials      164      164           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@riddhybansal riddhybansal left a comment

Choose a reason for hiding this comment

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

This LGTM 💯

@kennylam kennylam added this pull request to the merge queue Jan 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jan 29, 2025
@guidari guidari added this pull request to the merge queue Jan 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jan 30, 2025
@guidari guidari added this pull request to the merge queue Jan 30, 2025
Merged via the queue into carbon-design-system:main with commit 0d507e8 Jan 30, 2025
37 checks passed
@janhassel janhassel deleted the date-time-format-0-years branch January 31, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants