Ejemplo n.º 1
0
 def __sub__(self, other):
     if type(other) == int:
         daysdelta = timedelta(other)
         d = date.__sub__(self, daysdelta)
         return Day(d.year, d.month, d.day)
     else:
         return date.__sub__(self, other)
Ejemplo n.º 2
0
    def __sub__(self, other):
        result = date.__sub__(self, other)

        if result is NotImplemented:
            return result

        if isinstance(result, date):
            return self.from_datetime(result)
        else:
            return result
Ejemplo n.º 3
0
 def __sub__(self, x):
     """
     Sottrae 'x' dalla data; se x è di tipo numerico (int/float/long) viene
     restituita la data defalcata di 'x' giorni, altrimenti funzionalità
     standard della sottrazioe da un datetime.date di altro (timdelta)
     """
     if isinstance(x, (int, float, long)):
         #sottraggo un numero dalla data, detraggo in giorni
         return _date(self.year, self.month, self.day) - timedelta(days=x)
     d = date.__sub__(self, x)
     if isinstance(x, (_date, _datetime)):
         # data-data = timedelta, lo restituisco
         return d
     #sottrazione standard
     return _date(d.year, d.month, d.day)
Ejemplo n.º 4
0
 def __sub__(self, x):
     """
     Sottrae 'x' dalla data; se x è di tipo numerico (int/float/long) viene
     restituita la data defalcata di 'x' giorni, altrimenti funzionalità
     standard della sottrazioe da un datetime.date di altro (timdelta)
     """
     if isinstance(x, (int, float, long)):
         #sottraggo un numero dalla data, detraggo in giorni
         return _date(self.year, self.month, self.day)-timedelta(days=x)
     d = date.__sub__(self, x)
     if isinstance(x, (_date, _datetime)):
         # data-data = timedelta, lo restituisco
         return d
     #sottrazione standard
     return _date(d.year, d.month, d.day)
Ejemplo n.º 5
0
 def __sub__(self, other):
     result = date.__sub__(self, other)
     if not isinstance(result, timedelta):
         result = self.fromsolardate(result)
     return result
Ejemplo n.º 6
0
 def __sub__(self, other):
     result = date.__sub__(self, other)
     if not isinstance(result, timedelta):
         result = self.fromsolardate(result)
     return result
Ejemplo n.º 7
0
 def __sub__(self, td):
     newdate = date.__sub__(self, td)
     if isinstance(newdate, date):
         return ApexDate(newdate.year, newdate.month, newdate.day)
     return newdate # actually a timedelta
Ejemplo n.º 8
0
 def time_since(self, d: date) -> float:
     diff = date.__sub__(self, d)
     return diff.days / 365.25