MCPcopy Create free account
hub / github.com/github/gh-aw / resolveStopTime

Function resolveStopTime

pkg/workflow/stop_after.go:117–141  ·  view source on GitHub ↗

resolveStopTime resolves a stop-time value to an absolute timestamp If the stop-time is relative (starts with '+'), it calculates the absolute time from the compilation time. Otherwise, it parses the absolute time using various formats.

(stopTime string, compilationTime time.Time)

Source from the content-addressed store, hash-verified

115// If the stop-time is relative (starts with '+'), it calculates the absolute time
116// from the compilation time. Otherwise, it parses the absolute time using various formats.
117func resolveStopTime(stopTime string, compilationTime time.Time) (string, error) {
118 if stopTime == "" {
119 return "", nil
120 }
121
122 if isRelativeStopTime(stopTime) {
123 // Parse the relative time delta (minutes not allowed for stop-after)
124 delta, err := parseTimeDeltaForStopAfter(stopTime)
125 if err != nil {
126 return "", err
127 }
128
129 // Calculate absolute time in UTC using precise calculation
130 // Always use AddDate for months, weeks, and days for maximum precision
131 absoluteTime := compilationTime.UTC()
132 absoluteTime = absoluteTime.AddDate(0, delta.Months, delta.Weeks*7+delta.Days)
133 absoluteTime = absoluteTime.Add(time.Duration(delta.Hours)*time.Hour + time.Duration(delta.Minutes)*time.Minute)
134
135 // Format in the expected format: "YYYY-MM-DD HH:MM:SS"
136 return absoluteTime.Format("2006-01-02 15:04:05"), nil
137 }
138
139 // Parse absolute date-time with flexible format support
140 return parseAbsoluteDateTime(stopTime)
141}
142
143// ExtractStopTimeFromLockFile extracts the STOP_TIME value from a compiled workflow lock file
144func ExtractStopTimeFromLockFile(lockFilePath string) string {

Callers 3

TestResolveStopTimeFunction · 0.85

Calls 4

isRelativeStopTimeFunction · 0.85
parseAbsoluteDateTimeFunction · 0.85
AddMethod · 0.45

Tested by 2

TestResolveStopTimeFunction · 0.68