Exemple #1
0
    def __add__(self,o):

        other = Duration(o,"DURATION")      

        if not other.valid():
            return Duration(0,"DURATION")
  
        seconds = self.utc_seconds() + other.seconds()
    
        new = Time(seconds,self.name(),self.timezone())

        return new
Exemple #2
0
    def __add__(self, o):

        other = Duration(o, "DURATION")

        if not other.valid():
            return Duration(0, "DURATION")

        print self.utc_seconds(), other.seconds()
        seconds = self.utc_seconds() + other.seconds()

        new = Time(seconds, self.name(), self.timezone())

        return new
Exemple #3
0
    def __sub__(self, o):

        if isinstance(o, Time):
            # Subtract a time from this time and return a duration
            seconds = self.utc_seconds() - o.utc_seconds()
            return Duration(seconds)
        elif isinstance(o, Duration):
            # Subtract a duration from this time and return a time
            other = Duration(o)
            if (not other.valid()):
                return Time()

            seconds = self.utc_seconds() - other.seconds()
            return Time(seconds)
        else:
            raise TypeError, "subtraction with Time reqires Time or Duration"
Exemple #4
0
    def __sub__(self,o):

        
        if isinstance(o,Time):
            # Subtract a time from this time and return a duration
            seconds = self.utc_seconds() - other.utc_seconds()
            return Duration(seconds)
        elif isinstance(o,Duration):
            # Subtract a duration from this time and return a time
            other = Duration(o)
            if(not other.valid()):
                return Time()

            seconds = self.utc_seconds() - other.seconds()
            return Time(seconds)
        else:
            raise TypeError, "subtraction with Time reqires Time or Duration"
Exemple #5
0
#!/usr/bin/env python