Skip to content

Commit 67c089c

Browse files
committed
Convert created_at and finished_at to datetime objects in set_attributes. Convert floating point values from string to floats.
1 parent 202ce73 commit 67c089c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/judge0/submission.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
from typing import Union
23

34
from .base_types import LanguageAlias, Status
@@ -125,11 +126,21 @@ def set_attributes(self, attributes):
125126
continue
126127

127128
if attr in ENCODED_FIELDS:
128-
setattr(self, attr, decode(value) if value else None)
129+
value = decode(value) if value else None
129130
elif attr == "status":
130-
self.status = Status(value["id"])
131-
else:
132-
setattr(self, attr, value)
131+
value = Status(value["id"])
132+
elif attr in ("created_at", "finished_at"):
133+
value = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ")
134+
elif attr in (
135+
"wall_time",
136+
"wall_time_limit",
137+
"cpu_extra_time",
138+
"cpu_time_limit",
139+
"time",
140+
):
141+
value = float(value)
142+
143+
setattr(self, attr, value)
133144

134145
# TODO: Rename to as_body that accepts a Client.
135146
def to_dict(self, client: "Client") -> dict:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy