def __lt__(self, other): if self.utcoffset() is None and other.utcoffset() is None: return datetime.__lt__(self, other) elif self.utcoffset() is not None and other.utcoffset() is not None: us = datetime.__sub__(self.replace(tzinfo=None), self.utcoffset()) uo = datetime.__sub__(other.replace(tzinfo=None), other.utcoffset()) return us < uo else: raise TypeError("Can't compare naive and aware datetimes")
def __eq__(self, other): if self.utcoffset() is None and other.utcoffset() is None: return datetime.__eq__(self, other) elif self.utcoffset() is None or other.utcoffset() is None: raise TypeError('Cannot compare naive and aware datetimes') else: us = datetime.__sub__(self.replace(tzinfo=None), self.utcoffset()) uo = datetime.__sub__(other.replace(tzinfo=None), other.utcoffset()) return us == uo
def __sub__(self, other): if isinstance(other, timedelta): # Use __add__ implementation if it's datetime and timedelta return self + (-1) * other else: return datetime.__sub__(self.replace(tzinfo=None), other.replace(tzinfo=None))
def __sub__(self, other): if isinstance(other, timedelta): # Use __add__ implementation if it's datetime and timedelta return self + (-1) * other else: return datetime.__sub__(self.astimezone(UTC), other.astimezone(UTC))
def __sub__(self, arg): if isinstance(arg, AbsTime): return self.unixTime() - arg.unixTime() elif isinstance(arg, int) or isinstance(arg, long) or isinstance(arg, float): offset = arg key = {"seconds": offset} dt = datetime.__sub__(self, timedelta(**key)) return self._fromDateTime(dt)
def __sub__(self, other): result = datetime.__sub__(self, other) if result is NotImplemented: return result if isinstance(result, datetime): return self.from_datetime(result) else: return result
def __sub__(self, t): if isinstance(t, (Date, datetime)): # Subtracting two dates returns a Time. t = datetime.__sub__(self, t) return Time(+t.days, +t.seconds, microseconds=+t.microseconds) if isinstance(t, (Time, timedelta)): return self + Time(-t.days, -t.seconds, microseconds=-t.microseconds, months=-getattr(t, "months", 0), years=-getattr(t, "years", 0))
def __sub__(self, other): """Subtract other gpsdatetime or datetime to produce timedelta, or subtract timedelta to produce gpsdatetime. If one or both timezones are TAIOffset, leap seconds are included in the difference. Otherwise they're not. """ if not isinstance(other, datetime): if isinstance(other, timedelta): return self.__add__(-other) return NotImplemented if isnaive(self) != isnaive(other): raise TypeError('Cannot mix naive and timezone-aware datetimes') if isnaive(self) or (not isinstance(self.tzinfo, TAIOffset) and not isinstance(other.tzinfo, TAIOffset)): return datetime.__sub__(self, other) off = datetime.__sub__(self.replace(tzinfo=None), other.replace(tzinfo=None)) off += taioffset(other) - taioffset(self) return off
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 _datetime(self.year, self.month, self.day, self.hour, self.minute, self.second)-timedelta(days=x) d = dtime.__sub__(self, x) if isinstance(x, (_date, _datetime)): # data-data = timedelta, lo restituisco return d #sottrazione standard return _datetime(d.year, d.month, d.day, d.hour, d.minute, d.second)
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 _datetime(self.year, self.month, self.day, self.hour, self.minute, self.second) - timedelta(days=x) d = dtime.__sub__(self, x) if isinstance(x, (_date, _datetime)): # data-data = timedelta, lo restituisco return d #sottrazione standard return _datetime(d.year, d.month, d.day, d.hour, d.minute, d.second)
def __sub__(self, other): return datetimedict.fromdatetime(datetime.__sub__(self, other))
def _sub_and_convert(a, b): d = datetime.__sub__(a, b) if isinstance(d, datetime): return T(d) else: return d
title="Upcoming Events! :alarm_clock:", description="See what's happening in the next hour!", color=discord.Colour.dark_purple(), ) #assumes events in list are in chronological order for num, event in enumerate(events): <<<<<<< HEAD event_time, event_name, link = event left = dt.strptime(f"2021 October {day} {event_time}", "%Y %b %d %I:%M %p").replace(tzinfo=cst) ======= event_time, event_name, link = event left = dt.strptime(f"2021 May {day} {event_time}", "%Y %b %d %I:%M %p").replace(tzinfo=cst) >>>>>>> fb1d025f3d8eed90f94d9173a47e8da755c3bba1 if left > austin(): #check that event hasn't passed if (dt.__sub__(left, austin()).total_seconds()) <= 60: # event happening in the next minute text = f"{event_name} starting now!" embed.add_field( name=f"{val}. {event_name} at {event_time} CT", value=("in < 1 minute" + (f", [**link**]({link})" if link else "")), inline=False, ) elif (dt.__sub__(left, austin()).total_seconds()) <= 3600: # event happening in the next hour embed.add_field( name=f"{val}. {event_name} at {event_time} CT", value=(f"in {time_left(left)}" + (f", [**link**]({link})" if link else "")), inline=False, ) val = val + 1 else: break
def __sub__(self, td): newdt = datetime.__sub__(self, td) if isinstance(newdt, datetime): return ApexDatetime.from_iso(newdt.isoformat()) return newdt # actually a timedelta