@@ -6,8 +6,12 @@ import (
66 "strconv"
77 "strings"
88 "time"
9+
10+ "github.com/githubnext/gh-aw/pkg/logger"
911)
1012
13+ var timeDeltaLog = logger .New ("workflow:time_delta" )
14+
1115// Pre-compiled regexes for time parsing (performance optimization)
1216var (
1317 timeDeltaPattern = regexp .MustCompile (`(\d+)(mo|w|d|h|m)` )
@@ -53,12 +57,15 @@ func parseTimeDeltaForStopAfter(deltaStr string) (*TimeDelta, error) {
5357
5458// parseTimeDeltaWithMinutes parses a relative time delta string with optional minute support
5559func parseTimeDeltaWithMinutes (deltaStr string , allowMinutes bool ) (* TimeDelta , error ) {
60+ timeDeltaLog .Printf ("Parsing time delta: input=%s, allowMinutes=%v" , deltaStr , allowMinutes )
61+
5662 if deltaStr == "" {
5763 return nil , fmt .Errorf ("empty time delta" )
5864 }
5965
6066 // Must start with '+'
6167 if ! strings .HasPrefix (deltaStr , "+" ) {
68+ timeDeltaLog .Printf ("Time delta validation failed: missing '+' prefix" )
6269 return nil , fmt .Errorf ("time delta must start with '+', got: %s" , deltaStr )
6370 }
6471
@@ -148,6 +155,7 @@ func parseTimeDeltaWithMinutes(deltaStr string, allowMinutes bool) (*TimeDelta,
148155 return nil , fmt .Errorf ("time delta too large: %d minutes exceeds maximum of 525600 minutes" , delta .Minutes )
149156 }
150157
158+ timeDeltaLog .Printf ("Parsed time delta successfully: %s" , delta .String ())
151159 return delta , nil
152160}
153161
@@ -182,6 +190,8 @@ func isRelativeStopTime(stopTime string) bool {
182190
183191// parseAbsoluteDateTime parses various date-time formats and returns a standardized timestamp
184192func parseAbsoluteDateTime (dateTimeStr string ) (string , error ) {
193+ timeDeltaLog .Printf ("Parsing absolute date-time: %s" , dateTimeStr )
194+
185195 // Try multiple date-time formats in order of preference
186196 formats := []string {
187197 // Standard formats
@@ -236,7 +246,9 @@ func parseAbsoluteDateTime(dateTimeStr string) (string, error) {
236246 for _ , format := range formats {
237247 if parsed , err := time .Parse (format , dateTimeStr ); err == nil {
238248 // Successfully parsed, convert to UTC and return in standard format
239- return parsed .UTC ().Format ("2006-01-02 15:04:05" ), nil
249+ result := parsed .UTC ().Format ("2006-01-02 15:04:05" )
250+ timeDeltaLog .Printf ("Successfully parsed date-time using format, result: %s" , result )
251+ return result , nil
240252 }
241253 }
242254
@@ -247,7 +259,9 @@ func parseAbsoluteDateTime(dateTimeStr string) (string, error) {
247259 for _ , format := range formats {
248260 if parsed , err := time .Parse (format , normalizedStr ); err == nil {
249261 // Successfully parsed, convert to UTC and return in standard format
250- return parsed .UTC ().Format ("2006-01-02 15:04:05" ), nil
262+ result := parsed .UTC ().Format ("2006-01-02 15:04:05" )
263+ timeDeltaLog .Printf ("Successfully parsed date-time using ordinal normalization, result: %s" , result )
264+ return result , nil
251265 }
252266 }
253267
0 commit comments