4 # Copyright (C) 2010 Stefanos Harhalakis
6 # This file is part of maegirls.
8 # maegirls is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # maegirls is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with maegirls. If not, see <http://www.gnu.org/licenses/>.
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
30 self.setReference(t, 28)
32 # set day "day" as the reference day of starting period cycle
33 # day is int(time.time()/86400)
34 # cycle is the cycle width in days, starting from 0
35 def setReference(self, day, cycle):
39 # Convert an arbitary day to a day in cycle
40 def dayInCycle(self, day):
41 d=(day-self.refday) % self.cycle
47 def cycleLength(self):
50 def currentDayInCycle(self):
52 return(self.dayInCycle(d))
56 # 'status': ['ok', 'red']
57 # 'day': day in status
58 # 'len': length of status
61 # e.g. ret={'status':'red', 'day':0, 'len':5}
62 # means that it is in red, in the first of 5
63 def status(self, day):
64 d=self.dayInCycle(day)
78 'day': 6+d-self.cycle,
81 elif d>self.cycle-ovbefore-4 and d<=self.cycle-ovbefore:
84 'day': d-self.cycle+ovbefore+3,
87 elif d>self.cycle-16 and d<=self.cycle-ovbefore+1:
103 t=time.time() + time.timezone
109 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: