source: geniuswebcore/geniusweb/progress/ProgressFactory.py@ 65

Last change on this file since 65 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 1000 bytes
Line 
1from datetime import datetime
2
3from geniusweb.deadline.Deadline import Deadline
4from geniusweb.deadline.DeadlineRounds import DeadlineRounds
5from geniusweb.deadline.DeadlineTime import DeadlineTime
6from geniusweb.progress.Progress import Progress
7from geniusweb.progress.ProgressRounds import ProgressRounds
8from geniusweb.progress.ProgressTime import ProgressTime
9
10
11class ProgressFactory:
12 @staticmethod
13 def create( deadline: Deadline, nowms:int) -> Progress :
14 '''
15 @param deadline the deadline to create a progress for
16 @param nowms The time as from {@link System#currentTimeMillis()} that
17 is to be used as start time for the progress.
18 @return new Progress matching the deadline type.
19 '''
20 assert isinstance(deadline, Deadline)
21 if isinstance(deadline,DeadlineRounds):
22 return ProgressRounds( deadline.getRounds(),
23 0, datetime.fromtimestamp(nowms + deadline.getDuration()))
24 else:
25 return ProgressTime(deadline.getDuration(),datetime.fromtimestamp(nowms))
Note: See TracBrowser for help on using the repository browser.