<s> import arcpy <EOL> import datetime <EOL> import sys <EOL> import time <EOL> try : <EOL> nextfeat , srch_cursor = None , None <EOL> updatefeat , updt_cursor = None , None <EOL> inPoints = arcpy . GetParameterAsText ( <NUM_LIT:0> ) <EOL> inDateField = arcpy . GetParameterAsText ( <NUM_LIT:1> ) <EOL> inDeltaTimeField = arcpy . GetParameterAsText ( <NUM_LIT:2> ) <EOL> inTrackIDField = arcpy . GetParameterAsText ( <NUM_LIT:3> ) <EOL> fields = inDateField + '<STR_LIT:;>' + inDeltaTimeField <EOL> if inTrackIDField : <EOL> fields += '<STR_LIT:;>' + inTrackIDField <EOL> if ( sys . version_info . major < <NUM_LIT:3> ) : <EOL> srch_cursor = arcpy . SearchCursor ( inPoints , "<STR_LIT>" , None , fields , inDateField + "<STR_LIT>" ) <EOL> else : <EOL> srch_cursor = arcpy . gp . SearchCursor ( inPoints , "<STR_LIT>" , None , fields , inDateField + "<STR_LIT>" ) <EOL> nextfeat = next ( srch_cursor ) <EOL> nextfeat = next ( srch_cursor ) <EOL> if ( sys . version_info . major < <NUM_LIT:3> ) : <EOL> updt_cursor = arcpy . UpdateCursor ( inPoints , "<STR_LIT>" , None , fields , inDateField + "<STR_LIT>" ) <EOL> else : <EOL> updt_cursor = arcpy . gp . UpdateCursor ( inPoints , "<STR_LIT>" , None , fields , inDateField + "<STR_LIT>" ) <EOL> updatefeat = next ( updt_cursor ) <EOL> lastdt = None <EOL> lastid , thisid , nextid = None , None , None <EOL> try : <EOL> while updatefeat : <EOL> thisdt = updatefeat . getValue ( inDateField ) <EOL> if inTrackIDField : <EOL> thisid = updatefeat . getValue ( inTrackIDField ) <EOL> if thisid != lastid : <EOL> lastdt = None <EOL> if nextfeat : <EOL> if inTrackIDField : <EOL> nextid = nextfeat . getValue ( inTrackIDField ) <EOL> if thisid == nextid : <EOL> nextdt = nextfeat . getValue ( inDateField ) <EOL> else : <EOL> nextdt = None <EOL> else : <EOL> nextdt = None <EOL> if lastdt : <EOL> if nextdt : <EOL> span = ( nextdt - lastdt ) <EOL> else : <EOL> span = ( thisdt - lastdt ) <EOL> else : <EOL> if nextdt : <EOL> span = ( nextdt - thisdt ) <EOL> else : <EOL> span = None <EOL> if span : <EOL> span = float ( span . seconds ) / <NUM_LIT:2> <EOL> updatefeat . setValue ( inDeltaTimeField , span ) <EOL> updt_cursor . updateRow ( updatefeat ) <EOL> lastid = thisid <EOL> lastdt = thisdt <EOL> updatefeat = next ( updt_cursor ) <EOL> if updatefeat : <EOL> nextfeat = next ( srch_cursor ) <EOL> except StopIteration : <EOL> pass <EOL> arcpy . SetParameterAsText ( <NUM_LIT:4> , inPoints ) <EOL> except Exception as err : <EOL> import traceback <EOL> arcpy . AddError ( <EOL> traceback . format_exception_only ( type ( err ) , err ) [ <NUM_LIT:0> ] . rstrip ( ) ) <EOL> finally : <EOL> if nextfeat : <EOL> del nextfeat <EOL> if srch_cursor : <EOL> del srch_cursor <EOL> if updatefeat : <EOL> del updatefeat <EOL> if updt_cursor : <EOL> del updt_cursor </s>
