Skip to content

Commit 8abead1

Browse files
Fix date parsing bug (#106)
Co-authored-by: Christopher Harrop <Christopher.W.Harrop@noaa.gov>
1 parent 96277ae commit 8abead1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/workflowmgr/slurmbatchsystem.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,21 @@ def refresh_jobqueue(jobids)
462462
record[:queue]=job[90..109].strip
463463

464464
# Extract the submit time
465-
record[:submit_time]=Time.local(*job[110..139].strip.split(/[-:T]/)).getgm
465+
if job[110..139].strip =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
466+
record[:submit_time]=Time.local(*job[110..139].strip.split(/[-:T]/)).getgm
467+
else
468+
record[:submit_time]=nil
469+
end
466470

467471
# Extract the start time
468-
if job[140..169].strip != "N/A"
472+
if job[140..169].strip =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
469473
record[:start_time]=Time.local(*job[140..169].strip.split(/[-:T]/)).getgm
470474
else
471475
record[:start_time]=nil
472476
end
473477

474478
# Extract the end time
475-
if job[170..199].strip != "N/A"
479+
if job[170..199].strip =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
476480
record[:end_time]=Time.local(*job[170..199].strip.split(/[-:T]/)).getgm
477481
else
478482
record[:end_time]=nil
@@ -602,17 +606,21 @@ def refresh_jobacct(delta_days)
602606
record[:queue]=jobfields[3]
603607

604608
# Extract the submit time
605-
record[:submit_time]=Time.local(*jobfields[5].split(/[-:T]/)).getgm
609+
if jobfields[5] =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
610+
record[:submit_time]=Time.local(*jobfields[5].split(/[-:T]/)).getgm
611+
else
612+
record[:submit_time]=nil
613+
end
606614

607615
# Extract the start time
608-
if jobfields[6] != "None"
616+
if jobfields[6] =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
609617
record[:start_time]=Time.local(*jobfields[6].split(/[-:T]/)).getgm
610618
else
611619
record[:start_time]=nil
612620
end
613621

614622
# Extract the end time
615-
if jobfields[7] != "None"
623+
if jobfields[7] =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d$/
616624
record[:end_time]=Time.local(*jobfields[7].split(/[-:T]/)).getgm
617625
else
618626
record[:end_time]=nil

0 commit comments

Comments
 (0)