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

time: remove unnecessary if condition segment Mon <= dec31wday since it is always true in ISOWeek() #22241

Closed
msimonsson opened this issue Oct 12, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@msimonsson
Copy link

commented Oct 12, 2017

Hi,

In ISOWeek() Mon is the first day of the week.

https://github.com/golang/go/blob/master/src/time/time.go#L565

if dec31wday := (wday + 31 - day) % 7; Mon <= dec31wday && dec31wday <= Wed {

The condition Mon <= dec31wday is always true and the line can be changed to:

if dec31wday := (wday + 31 - day) % 7; dec31wday <= Wed {

@odeke-em odeke-em changed the title time: if condition is always true in ISOWeek() time: remove unnecessary if condition segment Mon <= dec31wday since it is always true in ISOWeek() Oct 12, 2017

@odeke-em

This comment has been minimized.

Copy link
Member

commented Oct 12, 2017

/cc @rsc

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2018

I think the code is clear, and removing the condition won't make it clearer.

@golang golang locked and limited conversation to collaborators Mar 29, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.