Skip to content

Implement parsing and formatting days-of-year #417

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

Merged
merged 3 commits into from
Oct 30, 2024
Merged

Conversation

dkhalanskyjb
Copy link
Collaborator

Fixes #414


override fun hashCode(): Int =
year.hashCode() * 31 + monthNumber.hashCode() * 31 + dayOfMonth.hashCode() * 31 + isoDayOfWeek.hashCode() * 31
year.hashCode() * 31 + monthNumber.hashCode() * 31 + dayOfMonth.hashCode() * 31 + isoDayOfWeek.hashCode() * 31 +
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the multiplication by 31 is useless here, these hashcodes could just be all summed

Copy link
Member

@ilya-g ilya-g Oct 29, 2024

Choose a reason for hiding this comment

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

On the other hand, a list-like data structure (e.g. a tuple can be represented as a list of its component values) usually implements hashCode where the position of element matters, so for example the dates 2024-04-05 and 2024-05-04 would have different hash codes.
But if this type is internal and not used much in hashsets/maps, this consideration is minor and the hashCode can be implemented anyhow within its contract.

@dkhalanskyjb dkhalanskyjb marked this pull request as ready for review August 22, 2024 08:10
@dkhalanskyjb dkhalanskyjb requested a review from ilya-g August 22, 2024 08:10
@dkhalanskyjb dkhalanskyjb merged commit fbb2187 into master Oct 30, 2024
1 check failed
@dkhalanskyjb dkhalanskyjb deleted the format-dayOfYear branch October 30, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a dayOfYear option
2 participants