Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: Reliable way to obtain start, end days of a month #31142
Hey, I noticed that the stdlib
Would be good to have a standard method to call for this common use case, rather than relying on the community to get complex date and time rules right.
The first day of a month seems straightforward:
monthStart := time.Date(d.Year(), d.Month(), 1, 0, 0, 0, 0, d.Location())
and the last day of the month is only slightly more complicated:
monthEnd := time.Date(d.Year(), d.Month() + 1, 0, 0, 0, 0, 0, d.Location())
@mcandre - Does this suffice your needs or you would still prefer to have a helper for this ? IMO, this method just leverages the standard date normalization behavior and lets users get their desired output.
If you would like this to be added in standard library, some usages of this in the real world will be helpful for us to make a decision. We would need to understand why such a helper needs to be in the standard library and not exist as a third party package.