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

Function calculateTimeRemaining

pkg/cli/status_command.go:302–338  ·  view source on GitHub ↗

Removed duplicate code - now everything goes through GetWorkflowStatuses calculateTimeRemaining calculates and formats the time remaining until stop-time

(stopTimeStr string)

Source from the content-addressed store, hash-verified

300
301// calculateTimeRemaining calculates and formats the time remaining until stop-time
302func calculateTimeRemaining(stopTimeStr string) string {
303 if stopTimeStr == "" {
304 return "N/A"
305 }
306
307 // Parse the stop time in local timezone
308 stopTime, err := time.ParseInLocation("2006-01-02 15:04:05", stopTimeStr, time.Local)
309 if err != nil {
310 return "Invalid"
311 }
312
313 now := time.Now()
314 remaining := stopTime.Sub(now)
315
316 // If already past the stop time
317 if remaining <= 0 {
318 return "Expired"
319 }
320
321 // Format the remaining time in a human-readable way
322 days := int(remaining.Hours() / 24)
323 hours := int(remaining.Hours()) % 24
324 minutes := int(remaining.Minutes()) % 60
325
326 if days > 0 {
327 if days == 1 {
328 return fmt.Sprintf("%dd %dh", days, hours)
329 }
330 return fmt.Sprintf("%dd %dh", days, hours)
331 } else if hours > 0 {
332 return fmt.Sprintf("%dh %dm", hours, minutes)
333 } else if minutes > 0 {
334 return fmt.Sprintf("%dm", minutes)
335 } else {
336 return "< 1m"
337 }
338}
339
340// isCompiledUpToDate checks if a workflow's lock file is up to date with the current source
341// using hash-based comparison. Falls back to "Yes" when no hash is available (legacy lock files).

Callers 2

GetWorkflowStatusesFunction · 0.85

Calls

no outgoing calls

Tested by 1