@@ -353,7 +353,7 @@ async def __get_launch_url(self, launch_uuid_future: Union[Optional[str], Task[O
353353 async def start_launch (
354354 self ,
355355 name : str ,
356- start_time : Union [ str , datetime ] ,
356+ start_time : str ,
357357 * ,
358358 description : Optional [str ] = None ,
359359 attributes : Optional [Union [list , dict ]] = None ,
@@ -406,7 +406,7 @@ async def start_test_item(
406406 self ,
407407 launch_uuid : Union [str , Task [str ]],
408408 name : str ,
409- start_time : Union [ str , datetime ] ,
409+ start_time : str ,
410410 item_type : str ,
411411 * ,
412412 parent_item_id : Optional [Union [str , Task [str ]]] = None ,
@@ -482,7 +482,7 @@ async def finish_test_item(
482482 self ,
483483 launch_uuid : Union [str , Task [str ]],
484484 item_id : Union [str , Task [str ]],
485- end_time : Union [ str , datetime ] ,
485+ end_time : str ,
486486 * ,
487487 status : Optional [str ] = None ,
488488 description : Optional [str ] = None ,
@@ -539,7 +539,7 @@ async def finish_test_item(
539539 async def finish_launch (
540540 self ,
541541 launch_uuid : Union [str , Task [str ]],
542- end_time : Union [ str , datetime ] ,
542+ end_time : str ,
543543 * ,
544544 status : Optional [str ] = None ,
545545 attributes : Optional [Union [list , dict ]] = None ,
@@ -947,7 +947,13 @@ async def start_launch(
947947 if not self .use_own_launch :
948948 return self .launch_uuid
949949 launch_uuid = await self .__client .start_launch (
950- name , start_time , description = description , attributes = attributes , rerun = rerun , rerun_of = rerun_of , ** kwargs
950+ name ,
951+ await self ._convert_time (start_time ),
952+ description = description ,
953+ attributes = attributes ,
954+ rerun = rerun ,
955+ rerun_of = rerun_of ,
956+ ** kwargs ,
951957 )
952958 self .__launch_uuid = launch_uuid
953959 return self .launch_uuid
@@ -993,7 +999,7 @@ async def start_test_item(
993999 item_id = await self .__client .start_test_item (
9941000 self .__launch_uuid ,
9951001 name ,
996- start_time ,
1002+ await self . _convert_time ( start_time ) ,
9971003 item_type ,
9981004 description = description ,
9991005 attributes = attributes ,
@@ -1045,7 +1051,7 @@ async def finish_test_item(
10451051 result = await self .__client .finish_test_item (
10461052 self .__launch_uuid ,
10471053 item_id ,
1048- end_time ,
1054+ await self . _convert_time ( end_time ) ,
10491055 status = status ,
10501056 issue = issue ,
10511057 attributes = attributes ,
@@ -1075,7 +1081,7 @@ async def finish_launch(
10751081 """
10761082 if self .use_own_launch :
10771083 result = await self .__client .finish_launch (
1078- self .__launch_uuid , end_time , status = status , attributes = attributes , ** kwargs
1084+ self .__launch_uuid , await self . _convert_time ( end_time ) , status = status , attributes = attributes , ** kwargs
10791085 )
10801086 else :
10811087 result = ""
@@ -1173,6 +1179,13 @@ async def use_microseconds(self) -> Optional[bool]:
11731179 self ._use_microseconds = False
11741180 return self ._use_microseconds
11751181
1182+ async def _convert_time (self , time_value : Union [str , datetime ]) -> str :
1183+ if isinstance (time_value , str ):
1184+ return time_value
1185+ if await self .use_microseconds ():
1186+ return time_value .strftime ("%Y-%m-%dT%H:%M:%S.%f%z" )
1187+ return str (int (time_value .timestamp () * 1000 ))
1188+
11761189 async def log (
11771190 self ,
11781191 time : Union [str , datetime ],
@@ -1200,7 +1213,7 @@ async def log(
12001213 truncate_fields_enabled = None ,
12011214 replace_binary_characters = None ,
12021215 launch_uuid = self .__launch_uuid ,
1203- time = time ,
1216+ time = await self . _convert_time ( time ) ,
12041217 file = rp_file ,
12051218 item_uuid = item_id ,
12061219 level = rp_level ,
@@ -1475,7 +1488,13 @@ def start_launch(
14751488 if not self .own_launch :
14761489 return self .launch_uuid
14771490 launch_uuid_coro = self .__client .start_launch (
1478- name , start_time , description = description , attributes = attributes , rerun = rerun , rerun_of = rerun_of , ** kwargs
1491+ name ,
1492+ self ._convert_time (start_time ),
1493+ description = description ,
1494+ attributes = attributes ,
1495+ rerun = rerun ,
1496+ rerun_of = rerun_of ,
1497+ ** kwargs ,
14791498 )
14801499 self .__launch_uuid = self .create_task (launch_uuid_coro )
14811500 return self .launch_uuid
@@ -1521,7 +1540,7 @@ def start_test_item(
15211540 item_id_coro = self .__client .start_test_item (
15221541 self .launch_uuid ,
15231542 name ,
1524- start_time ,
1543+ self . _convert_time ( start_time ) ,
15251544 item_type ,
15261545 description = description ,
15271546 attributes = attributes ,
@@ -1571,7 +1590,7 @@ def finish_test_item(
15711590 result_coro = self .__client .finish_test_item (
15721591 self .launch_uuid ,
15731592 item_id ,
1574- end_time ,
1593+ self . _convert_time ( end_time ) ,
15751594 status = status ,
15761595 issue = issue ,
15771596 attributes = attributes ,
@@ -1603,7 +1622,7 @@ def finish_launch(
16031622 self .create_task (self .__client .log_batch (self ._log_batcher .flush ()))
16041623 if self .own_launch :
16051624 result_coro = self .__client .finish_launch (
1606- self .launch_uuid , end_time , status = status , attributes = attributes , ** kwargs
1625+ self .launch_uuid , self . _convert_time ( end_time ) , status = status , attributes = attributes , ** kwargs
16071626 )
16081627 else :
16091628 result_coro = self .__empty_str ()
@@ -1697,6 +1716,13 @@ def use_microseconds(self) -> Task[bool]:
16971716 return self .create_task (self ._return_value (self ._use_microseconds ))
16981717 return self .create_task (self .__resolve_use_microseconds ())
16991718
1719+ def _convert_time (self , time_value : Union [str , datetime ]) -> str :
1720+ if isinstance (time_value , str ):
1721+ return time_value
1722+ if self .use_microseconds ().blocking_result ():
1723+ return time_value .strftime ("%Y-%m-%dT%H:%M:%S.%f%z" )
1724+ return str (int (time_value .timestamp () * 1000 ))
1725+
17001726 async def _log_batch (self , log_rq : Optional [list [AsyncRPRequestLog ]]) -> Optional [tuple [str , ...]]:
17011727 return await self .__client .log_batch (log_rq )
17021728
@@ -1730,7 +1756,7 @@ def log(
17301756 truncate_fields_enabled = None ,
17311757 replace_binary_characters = None ,
17321758 launch_uuid = self .launch_uuid ,
1733- time = time ,
1759+ time = self . _convert_time ( time ) ,
17341760 file = rp_file ,
17351761 item_uuid = item_id ,
17361762 level = rp_level ,
0 commit comments