Skip to content

Commit

Permalink
chore: fix timezone
Browse files Browse the repository at this point in the history
Signed-off-by: Dup4 <lyuzhi.pan@gmail.com>
  • Loading branch information
Dup4 committed Nov 14, 2023
1 parent 764d0d6 commit 722d80d
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions xcpcio_board_spider/spider/csg_cpc/v1/csg_cpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def fetch(self):

return self

def get_timestamp_from_date(self, dt):
return utils.get_timestamp_from_iso8601(dt.replace(" ", "T") + "+08:00")

def parse_teams(self):
teams = Teams()

Expand Down Expand Up @@ -177,26 +180,6 @@ def parse_result(self, result: int):

def parse_runs(self):
runs = Submissions()

"""
[
6,
1001,
1000,
"team111",
6,
"2023-05-13T15:33:27"
],
solution_id
contest_id
problem_id
user_id
result
in_date
"""

for raw_run in self.raw_run_data:
run = Submission()

Expand All @@ -205,7 +188,7 @@ def parse_runs(self):
team_id = str(raw_run["user_id"]).split("_")[-1]
result = int(raw_run["result"])
in_date = str(raw_run["in_date"]).replace("T", " ")
timestamp = utils.get_timestamp_second(
timestamp = self.get_timestamp_from_date(
in_date) - self.contest.start_time

run.submission_id = str(submission_id)
Expand All @@ -226,8 +209,8 @@ def update_contest(self):
end_time = self.raw_contest_data["end_time"]
frozen_minute = self.raw_contest_data["frozen_minute"]

self.contest.start_time = utils.get_timestamp_second(start_time)
self.contest.end_time = utils.get_timestamp_second(end_time)
self.contest.start_time = self.get_timestamp_from_date(start_time)
self.contest.end_time = self.get_timestamp_from_date(end_time)

self.contest.frozen_time = int(frozen_minute) * 60

Expand Down

0 comments on commit 722d80d

Please sign in to comment.