Add delta time syntax support to gh aw logs command with always-precise calculations#112
Add delta time syntax support to gh aw logs command with always-precise calculations#112
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
pkg/workflow/time_delta.go
Outdated
| // Calculate absolute time in UTC using precise calculation | ||
| var absoluteTime time.Time | ||
| if delta.Months > 0 || delta.Weeks > 0 { | ||
| // Use AddDate for months and weeks for more accurate calculation |
There was a problem hiding this comment.
Updated both resolveStopTime and ResolveRelativeDate functions to always use precise calculation with AddDate() for months, weeks, and days instead of conditional logic that falls back to simple duration arithmetic. Fixed in commit b2c860f.
…ns.md Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated instructions.md file to document the new delta time syntax support for the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
pkg/workflow/time_delta.go
Outdated
| duration := time.Duration(td.Days) * 24 * time.Hour | ||
| duration += time.Duration(td.Hours) * time.Hour | ||
| duration += time.Duration(td.Minutes) * time.Minute | ||
| duration += time.Duration(td.Weeks) * 7 * 24 * time.Hour |
There was a problem hiding this comment.
is this function still needed? @copilot remove if dead code
There was a problem hiding this comment.
Removed the toDuration function as it was dead code. The function was only used in tests and the application now exclusively uses precise calculations with AddDate() instead of approximate duration arithmetic. Also removed the associated test TestTimeDeltaToDuration. Fixed in commit fc7d906.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR adds support for delta time syntax (
-1d,-1w,-1mo) to the--start-dateand--end-dateflags in thegh aw logscommand, making it much easier to filter workflow runs using relative dates. Additionally, it improves precision across the entire time delta system by always using precise date calculations.New Delta Time Syntax
Users can now specify relative dates using intuitive syntax:
Supported Time Units
-1d,-7d-1w,-4w-1mo,-6mo-12h,-30m(for sub-day precision)-1mo2w3d,-2w5d12hAlways-Precise Date Calculations
Improved precision across the entire time delta system by eliminating conditional calculation logic:
AddDate()only when months/weeks were present, fell back to simple duration arithmetic otherwiseAddDate()for months, weeks, and days for maximum precision in all scenariosgh aw logscommand and existing workflowstop-timefield functionalityFor example, adding 1 day on a daylight saving boundary:
AddDate()which properly handles calendar day boundariesImplementation Details
The implementation extends the existing time delta parsing infrastructure from the compiler's
stop-timefield functionality:YYYY-MM-DDformat for GitHub CLIResolveRelativeDateandresolveStopTimefunctions by eliminating conditional logicinstructions.mdto document the new logs command functionalityBackward Compatibility
All existing functionality remains unchanged:
2024-01-01continue to work exactly as beforeExample Usage
The command automatically resolves these relative dates to absolute dates before calling the GitHub CLI, ensuring full compatibility with GitHub's API.
Testing
Added comprehensive test coverage with 95+ new test cases covering:
ResolveRelativeDateandresolveStopTimeFixes #111.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.