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 Utilities #68

Open
shahzadhaider1 opened this issue Dec 3, 2024 · 0 comments
Open

Time Utilities #68

shahzadhaider1 opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@shahzadhaider1
Copy link
Collaborator

Feature Description

We should add utility functions around time package


Use Case

It would be helpful to have different utility functions revolving around time.Time in our library. For example, function to round to nearest interval, function to convert unix milli to time.Time, function to convert times to human-readable format, check occurrence/before/after of specific time, etc.

Pseudo Code

// Provide a code snippet or example that demonstrates how this feature might be used

func UnixMilliToTime(ms int64) time.Time {
    return time.Unix(0, ms*int64(time.Millisecond))
}

func SplitDuration(d time.Duration) (days, hours, minutes, seconds int) {
    days = int(d.Hours()) / 24
    hours = int(d.Hours()) % 24
    minutes = int(d.Minutes()) % 60
    seconds = int(d.Seconds()) % 60
    return
}
@shahzadhaider1 shahzadhaider1 added the enhancement New feature or request label Dec 3, 2024
@shahzadhaider1 shahzadhaider1 self-assigned this Dec 3, 2024
@kashifkhan0771 kashifkhan0771 added the good first issue Good for newcomers label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants