Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Rickard Lindberg, Roger Lindberg 2 # 3 # This file is part of Timeline. 4 # 5 # Timeline is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # Timeline is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with Timeline. If not, see <http://www.gnu.org/licenses/>. 17 18 19 from timelinelib.calendar.time import ComparableValue 20 from timelinelib.calendar.time import GenericDeltaMixin 21 from timelinelib.calendar.time import GenericTimeMixin 22 23 24 SECONDS_IN_DAY = 24 * 60 * 6028 29 MIN_JULIAN_DAY = 0 30 31 @property11433 return GregorianDelta34 35 @classmethod37 return cls(cls.MIN_JULIAN_DAY, 0)38 39 @classmethod41 if allow_negative_julian_yeras: 42 cls.MIN_JULIAN_DAY = -1000000000000000000000000000000000000000000000000 43 else: 44 cls.MIN_JULIAN_DAY = 04547 if julian_day < self.MIN_JULIAN_DAY: 48 raise ValueError("julian_day must be >= %d" % self.MIN_JULIAN_DAY) 49 if seconds < 0 or seconds >= SECONDS_IN_DAY: 50 raise ValueError("seconds must be >= 0 and <= 24*60*60") 51 self.julian_day = julian_day 52 self.seconds = seconds5355 return (isinstance(time, self.__class__) and 56 self.julian_day == time.julian_day and 57 self.seconds == time.seconds)5860 return not (self == time)6163 if isinstance(delta, self.DeltaClass): 64 seconds = self.seconds + delta.seconds 65 seconds_in_day = int(self.julian_day + seconds // SECONDS_IN_DAY) 66 return self.__class__(seconds_in_day, seconds % SECONDS_IN_DAY) 67 raise TypeError( 68 "%s + %s not supported" % (self.__class__.__name__, type(delta)) 69 )7072 if isinstance(other, self.DeltaClass): 73 seconds = self.seconds - other.seconds 74 if seconds < 0: 75 if seconds % SECONDS_IN_DAY == 0: 76 days = abs(seconds) // SECONDS_IN_DAY 77 seconds = 0 78 else: 79 days = abs(seconds) // SECONDS_IN_DAY + 1 80 seconds = SECONDS_IN_DAY - abs(seconds) % SECONDS_IN_DAY 81 return self.__class__(self.julian_day - days, seconds) 82 else: 83 return self.__class__(self.julian_day, seconds) 84 else: 85 days_diff = self.julian_day - other.julian_day 86 seconds_diff = self.seconds - other.seconds 87 return self.DeltaClass(days_diff * SECONDS_IN_DAY + seconds_diff)88 91 94 9799 return "{0}({1!r}, {2!r})".format( 100 self.__class__.__name__, 101 self.julian_day, 102 self.seconds 103 )104106 from timelinelib.calendar.gregorian.gregorian import GregorianDateTime 107 return GregorianDateTime.from_time(self)108117 118 @classmethod156120 return cls(seconds)121 122 @classmethod124 return cls(SECONDS_IN_DAY * days)125 126 @property128 return self.value129131 if isinstance(value, self.__class__): 132 return self.seconds / value.seconds 133 else: 134 return self.__class__(int(self.seconds // value))135 138 141 144146 return (self.seconds // (60 * 60)) % 24147149 return (self.seconds // 60) % 60150
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 25 02:55:27 2020 | http://epydoc.sourceforge.net |