On Nov 25, 5:16 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> peter wrote:
> >> >>> from datetime import *
> >> >>> class TS(datetime):
>
> >> ... def __new__(cls, ts):
> >> ... return datetime.fromtimestamp(ts)
> >> ...>>> TS(0)
>
> >> datetime.datetime(1970, 1, 1, 1, 0)
>
> >> work
peter wrote:
>> >>> from datetime import *
>> >>> class TS(datetime):
>>
>> ... def __new__(cls, ts):
>> ... return datetime.fromtimestamp(ts)
>> ...>>> TS(0)
>>
>> datetime.datetime(1970, 1, 1, 1, 0)
>>
>> works super() would be the most likely culprit.
>
> Yes, that works, excep
On Nov 25, 4:39 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> peter wrote:
> > On Nov 25, 3:46 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> >> peter wrote:
> >> import datetime
> >> class ts(datetime.datetime):
> >> > ... foo = 'bar'
> >> > ... def __new__(cls, s):
> >> > ...
peter wrote:
> On Nov 25, 3:46 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
>> peter wrote:
>> import datetime
>> class ts(datetime.datetime):
>> > ... foo = 'bar'
>> > ... def __new__(cls, s):
>> > ... c = super(ts, cls)
>> > ... return c.fromtimestamp(s)
>> > ...
On Nov 25, 3:46 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> peter wrote:
> import datetime
> class ts(datetime.datetime):
> > ... foo = 'bar'
> > ... def __new__(cls, s):
> > ... c = super(ts, cls)
> > ... return c.fromtimestamp(s)
> > ...
> t = ts(0)
> > Tra
peter wrote:
import datetime
class ts(datetime.datetime):
> ... foo = 'bar'
> ... def __new__(cls, s):
> ... c = super(ts, cls)
> ... return c.fromtimestamp(s)
> ...
t = ts(0)
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 5,
John Machin wrote:
> Lad wrote:
> > Sybren Stuvel wrote:
> > > Lad enlightened us with:
> > > > How can I find days and minutes difference between two datetime
> > > > objects?
> > > > For example If I have
> > > > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000)
> > > > a=datetime.datetime(200
Lad wrote:
> Sybren Stuvel wrote:
> > Lad enlightened us with:
> > > How can I find days and minutes difference between two datetime
> > > objects?
> > > For example If I have
> > > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000)
> > > a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000)
> >
>
I am a newcomer to python - so not too sure if this method is the correct one.
Noticing this,
>>> dir(diff)['__abs__', '__add__', '__class__', '__delattr__', '__div__', '__doc__', '__eq__', '__floordiv__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__mu
Sybren Stuvel wrote:
> Lad enlightened us with:
> > How can I find days and minutes difference between two datetime
> > objects?
> > For example If I have
> > b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000)
> > a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000)
>
> diff = b - a
Ok, I tried
Lad wrote:
> How can I find days and minutes difference between two datetime
> objects?
> For example If I have
> b=datetime.datetime(2006, 8, 2, 8, 57, 28, 687000)
> a=datetime.datetime(2006, 8, 1, 18, 19, 45, 765000)
a - b
Lookup datetime.timedelta - all of this is neatly documented.
Diez
--
11 matches
Mail list logo