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 $"
28 t=time.time() - time.timezone
35 'cycle': 28, # Cycle length
36 'menstr': 5, # Duration of menstruation
37 'ovday': -14, # When ovulation happens. Positive: This number
38 # of days after the start of the cycle.
39 # Negative: This number of days before the end
47 self.setReference(t, defaults)
49 # set day "day" as the reference day of starting period cycle
50 # day is int(time.time()/86400)
51 # cycle is the cycle width in days, starting from 0
52 def setReference(self, day, cfg):
56 # Convert an arbitary day to a day in cycle
57 def dayInCycle(self, day):
58 d=(day-self.refday) % self.cfg['cycle']
64 def cycleLength(self):
65 return(self.cfg['cycle'])
67 def currentDayInCycle(self):
69 return(self.dayInCycle(d))
71 def menstruationDuration(self):
72 return(self.cfg['menstr'])
74 def ovulationDay(self):
75 return(self.cfg['ovday'])
79 # 'status': ['ok', 'red']
80 # 'day': day in status
81 # 'len': length of status
84 # e.g. ret={'status':'red', 'day':0, 'len':5}
85 # means that it is in red, in the first of 5
86 def status(self, day):
87 d=self.dayInCycle(day)
89 cycle=self.cycleLength()
92 ovday=self.ovulationDay()
102 menstr=self.menstruationDuration()
117 elif d>=ovstart and d<=ovmid:
123 elif d>ovmid and d<=ovend:
139 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: