@@ -129,54 +129,53 @@ def to_string(ctx, coll):
129129
130130def to_date_time (ctx , coll ):
131131 ln = len (coll )
132- rtn = []
133132 if ln > 1 :
134133 raise Exception ("to_date_time called for a collection of length " + str (ln ))
135134
136- if ln = = 1 :
137- value = util . get_data ( coll [ 0 ])
135+ if ln ! = 1 :
136+ return []
138137
139- dateTimeObject = nodes .FP_DateTime (value )
138+ value = util .get_data (coll [0 ])
139+ dateTimeObject = nodes .FP_DateTime (value )
140140
141- if dateTimeObject :
142- rtn . append ( dateTimeObject )
141+ if not dateTimeObject :
142+ return []
143143
144- return util .get_data (rtn [ 0 ] )
144+ return util .get_data (dateTimeObject )
145145
146146
147147def to_time (ctx , coll ):
148148 ln = len (coll )
149- rtn = []
150149 if ln > 1 :
151150 raise Exception ("to_time called for a collection of length " + str (ln ))
152151
153- if ln = = 1 :
154- value = util . get_data ( coll [ 0 ])
152+ if ln ! = 1 :
153+ return []
155154
156- timeObject = nodes .FP_Time (value )
155+ value = util .get_data (coll [0 ])
156+ timeObject = nodes .FP_Time (value )
157157
158- if timeObject :
159- rtn . append ( timeObject )
158+ if not timeObject :
159+ return []
160160
161- return util .get_data (rtn [ 0 ] )
161+ return util .get_data (timeObject )
162162
163163
164164def to_date (ctx , coll ):
165165 ln = len (coll )
166- rtn = []
167-
168166 if ln > 1 :
169167 raise Exception ("to_date called for a collection of length " + str (ln ))
170168
171- if ln = = 1 :
172- value = util . get_data ( coll [ 0 ])
169+ if ln ! = 1 :
170+ return []
173171
174- dateObject = nodes .FP_DateTime (value )
172+ value = util .get_data (coll [0 ])
173+ dateObject = nodes .FP_DateTime (value )
175174
176- if dateObject :
177- rtn . append ( dateObject )
175+ if not dateObject :
176+ return []
178177
179- return util .get_data (rtn [ 0 ] )
178+ return util .get_data (dateObject )
180179
181180
182181def create_converts_to_fn (to_function , _type ):
0 commit comments