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

Add support for "week of month" in SimpleDateTimeFormatter #11103

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

NEUpanning
Copy link
Contributor

@NEUpanning NEUpanning commented Sep 26, 2024

java.text.SimpleDateFormat supports using 'week of month' to parse/format date. The specifier of 'week of month' is 'W'. Now DateTimeFormatter supports 3 group of fields specifying the day within the year. They are following combinations:

year + week + dayOfWeek
year + dayOfYear
year + month + day

This PR introduces a new combination that is year + month + weekOfMonth + dayOfWeek and adds support for "week of month" in SimpleDateTimeFormatter.

Relates issue : #10354

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 26, 2024
Copy link

netlify bot commented Sep 26, 2024

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit 9b14344
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67073c2e7cbac70008c17029

@NEUpanning NEUpanning marked this pull request as draft September 26, 2024 11:30
@NEUpanning NEUpanning marked this pull request as ready for review September 26, 2024 11:44
@NEUpanning
Copy link
Contributor Author

@rui-mo Could you help to review this PR please? Thanks.

Copy link
Collaborator

@rui-mo rui-mo left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me overall.

bool centuryFormat = false;

bool isYearOfEra = false; // Year of era cannot be zero or negative.
bool hasYear = false; // Whether year was explicitly specified.
bool hasYear = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: is the comment Whether year was explicitly specified. removed by accident?

Copy link
Contributor Author

@NEUpanning NEUpanning Oct 10, 2024

Choose a reason for hiding this comment

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

Thanks for catching that. Updated.

bool hasYear = false; // Whether year was explicitly specified.
bool hasYear = false;
// Whether dayOfWeek was explicitly specified.
bool hasDayOfWeek = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: perhaps follow the style of other comments to add comment after the code.

if (!date.weekOfMonthDateFormat) {
date.weekDateFormat = true;
}
date.hasDayOfWeek = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: perhaps put it near L1001.

@NEUpanning
Copy link
Contributor Author

@rui-mo I've updated code based on the feedback. Could you review it again? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants