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

civil: add AddMonths, AddYears and Weekday methods to Date, DateTime #11339

Closed
Vinayaka-B opened this issue Dec 21, 2024 · 4 comments
Closed
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@Vinayaka-B
Copy link
Contributor

Is your feature request related to a problem? Please describe.

While using Date and DateTime objects, there might be need for certain operations like -

  1. Getting the date n months in future from given date
  2. Getting the day of the week for a certain date

Describe the solution you'd like

Implementing the methods for the structs

Describe alternatives you've considered

User needs to convert object in time.Time struct do the above operation and convert back to the Date struct. That is inconvenient.

Additional context

Will create a PR for this soon

@Vinayaka-B Vinayaka-B added the triage me I really want to be triaged. label Dec 21, 2024
@Vinayaka-B
Copy link
Contributor Author

Vinayaka-B commented Dec 21, 2024

Avoided adding the methods for DateTime struct due to this comment in the code -

// Note: We deliberately do not embed Date into DateTime, to avoid promoting AddDays and Sub.

Don't fully understand why we need to avoid these methods (AddDays, AddMonths, Weekday) for the struct so I can update my PR if some maintainer can confirm that it is okay to add them

@quartzmo quartzmo added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Dec 30, 2024
@quartzmo quartzmo self-assigned this Dec 30, 2024
@quartzmo
Copy link
Member

@Vinayaka-B Thank you for suggesting these additions.

there might be need for certain operations like...

What is your immediate motivation for adding these functions now?

@Vinayaka-B
Copy link
Contributor Author

I was writing an application where I needed the above. I had to convert the Date struct object to time.Time object and then convert back to Date. While that is a working solution, I feel the problem is generic enough that this should be supported directly by the package.

@quartzmo
Copy link
Member

quartzmo commented Jan 7, 2025

Closed by #11340

@quartzmo quartzmo closed this as completed Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants