> I'd like to start with two dates as strings, as
> "1961/06/16 04:35:25" and "1973/01/18 03:45:50"
> How do I get the strings into a shape that will accommodate a difference?
Pyfdate http://www.ferg.org/pyfdate/index.html
has a numsplit function that should do the trick:
http://www.ferg.org/pyf
On Tue, Dec 29, 2009 at 7:21 AM, M.-A. Lemburg wrote:
> If you want a more human readable, relative format use Age():
>
> >>> Age(bree, nat)
> 0x2b99c6e37ef0>
>
> i.e. 8 years, 4 months, 29 days, 49 minutes, 35 seconds.
>
That is... awesome. I use mx.DateTime all the time, and never knew about
W. eWatson wrote:
> According to one web source, this program:
>
> import datetime
> bree = datetime.datetime(1981, 6, 16, 4, 35, 25)
> nat = datetime.datetime(1973, 1, 18, 3, 45, 50)
>
> difference = bree - nat
> print "There were", difference, "minutes between Nat and Bree"
>
> yields:
> Ther
W. eWatson wrote:
> Peter Otten wrote:
>> W. eWatson wrote:
>>
>>> This is quirky.
>>>
>>> >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
>>> >>> t1
>>> datetime.datetime(2009, 12, 5, 22, 11)
>>> >>> type(t1)
>>>
>>> >>>
>>> t1: 2009-12-05 22:11:00
>>>
>>> but in the pr
Peter Otten wrote:
W. eWatson wrote:
This is quirky.
>>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
>>> t1
datetime.datetime(2009, 12, 5, 22, 11)
>>> type(t1)
>>>
t1: 2009-12-05 22:11:00
but in the program:
import datetime
t1=datetime.datetime.strptime("2
This is quirky.
>>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
>>> t1
datetime.datetime(2009, 12, 5, 22, 11)
>>> type(t1)
>>>
t1: 2009-12-05 22:11:00
but in the program:
import datetime
t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
print "t1:
W. eWatson wrote:
> This is quirky.
>
> >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
> >>> t1
> datetime.datetime(2009, 12, 5, 22, 11)
> >>> type(t1)
>
> >>>
> t1: 2009-12-05 22:11:00
>
> but in the program:
> import datetime
>
> t1=datetime.datetime.strpt
"W. eWatson" writes:
> It doesn't seem to be standard practice to more or less teach the
> environment that Python is in. If they do, it's jumbled around. Most
> books start with Python itself and skirt the issues of the environment
> and interaction.
There are no Python documentation police enf
Steven D'Aprano wrote:
On Mon, 28 Dec 2009 23:50:30 +1100, Ben Finney wrote:
How does one "unload" this structure to get the seconds and days?
It's customary to consult the documentation for questions like that
http://docs.python.org/library/datetime.html#datetime.timedelta>.
No no no, it's
On Mon, 28 Dec 2009 23:22:09 +0100, Peter Otten wrote:
> print some_object
>
> first converts some_object to a string invoking str(some_object) which
> in turn calls the some_object.__str__() method. The resulting string is
> then written to stdout.
In fairness to the OP, that's a misleading wa
On Mon, 28 Dec 2009 14:42:21 -0800, W. eWatson wrote:
> So as long as I don't print it, it's datetime.datetime and I can make
> calculations or perform operations on it as though it is not a string,
> but a datetime object?
No, it remains a datetime object regardless of whether you print it or
n
On Mon, 28 Dec 2009 10:54:46 -0800, W. eWatson wrote:
> Ben Finney wrote:
>> "W. eWatson" writes:
>>
>>> Lie Ryan wrote:
what's strange about it? the difference between 2009/01/02 13:01:15
and 2009/01/04 13:01:15 is indeed 2 days... Can you elaborate what do
you mean by 'strange'?
W. eWatson wrote:
> Peter Otten wrote:
>> W. eWatson wrote:
>>
>>> This is quirky.
>>>
>>> >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S")
>>> >>> t1
>>> datetime.datetime(2009, 12, 5, 22, 11)
>>> >>> type(t1)
>>>
>>> >>>
>>> t1: 2009-12-05 22:11:00
>>>
>>> but in the
On Mon, 28 Dec 2009 23:50:30 +1100, Ben Finney wrote:
>> How does one "unload" this structure to get the seconds and days?
>
> It's customary to consult the documentation for questions like that
> http://docs.python.org/library/datetime.html#datetime.timedelta>.
No no no, it's customary to annoy
In article ,
Roy Smith wrote:
> Yes, but how much time has elapsed between "2009/0/04 13:01:15"
Typo. Should be "2009/01/04 13:01:15".
--
http://mail.python.org/mailman/listinfo/python-list
In article ,
"W. eWatson" wrote:
> BTW, all times are local to my city. Same time zone.
Yes, but how much time has elapsed between "2009/0/04 13:01:15" and
"2009/06/04 13:01:15"? Even if I tell you that both timestamps were done
in the same city, you don't have enough information.
Hint #1:
Ben Finney wrote:
"W. eWatson" writes:
Lie Ryan wrote:
what's strange about it? the difference between 2009/01/02 13:01:15
and 2009/01/04 13:01:15 is indeed 2 days... Can you elaborate what
do you mean by 'strange'?
Easily. In one case, it produces a one argument funcion, and the other
2,
D'Arcy J.M. Cain wrote:
On Mon, 28 Dec 2009 08:20:28 -0800
"W. eWatson" wrote:
Sort of the opposite of a stopped clock. It's right twice a day. How
does one solve the DST problem?
Depends on which DST problem you have. There is more than one solution
depending on what the problem is. Store
On Mon, 28 Dec 2009 08:20:28 -0800
"W. eWatson" wrote:
> Sort of the opposite of a stopped clock. It's right twice a day. How
> does one solve the DST problem?
Depends on which DST problem you have. There is more than one solution
depending on what the problem is. Store and compare in UTC and
Roy Smith wrote:
In article ,
"W. eWatson" wrote:
BTW, all times are local to my city. Same time zone.
Yes, but how much time has elapsed between "2009/0/04 13:01:15" and
"2009/06/04 13:01:15"? Even if I tell you that both timestamps were done
in the same city, you don't have enough info
On 12/29/2009 1:12 AM, Roy Smith wrote:
Hint #3: If you don't pay attention to this, you will be bitten twice a
year.
Not really. Some areas don't have DST and the answer to that is always
exactly 5 months.
--
http://mail.python.org/mailman/listinfo/python-list
"W. eWatson" writes:
> Lie Ryan wrote:
> > what's strange about it? the difference between 2009/01/02 13:01:15
> > and 2009/01/04 13:01:15 is indeed 2 days... Can you elaborate what
> > do you mean by 'strange'?
> Easily. In one case, it produces a one argument funcion, and the other
> 2, possib
Lie Ryan wrote:
On 12/28/2009 5:42 PM, W. eWatson wrote:
You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2,
13, 1, 15).
If I now use
t2=datetime.datetime.strptime("2009/01/04 13:01:15","%Y/%m/%d %H:%M:%S")
I get tw as
datetime.datetime(2009, 1, 4, 13, 1, 15)
Then t2-t1 gives
BTW, all times are local to my city. Same time zone.
--
http://mail.python.org/mailman/listinfo/python-list
In article ,
"W. eWatson" wrote:
> t1=datetime.datetime.strptime("2009/01/02 13:01:15","%y/%m/%d %H:%M:%S")
> doesn't do it.
> ValueError: time data did not match format: data=2009/01/02 13:01:15
> fmt=%y/%m/%d %H:%M:%S
The first thing that jumps out at me is that %y is the two-digit year. Y
On 12/28/2009 5:42 PM, W. eWatson wrote:
You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2,
13, 1, 15).
If I now use
t2=datetime.datetime.strptime("2009/01/04 13:01:15","%Y/%m/%d %H:%M:%S")
I get tw as
datetime.datetime(2009, 1, 4, 13, 1, 15)
Then t2-t1 gives,
datetime.timede
Ben Finney wrote:
"W. eWatson" writes:
How do I get the strings into a shape that will accommodate a difference?
For example,
t1=datetime.datetime.strptime("2009/01/02 13:01:15","%y/%m/%d %H:%M:%S")
doesn't do it.
ValueError: time data did not match format: data=2009/01/02 13:01:15
fmt=%y/%m
You're right. Y. Works fine. The produces datetime.datetime(2009, 1, 2,
13, 1, 15).
If I now use
t2=datetime.datetime.strptime("2009/01/04 13:01:15","%Y/%m/%d %H:%M:%S")
I get tw as
datetime.datetime(2009, 1, 4, 13, 1, 15)
Then t2-t1 gives,
datetime.timedelta(2)
which is a 2 day difference--I gue
"W. eWatson" writes:
> How do I get the strings into a shape that will accommodate a difference?
>
> For example,
> t1=datetime.datetime.strptime("2009/01/02 13:01:15","%y/%m/%d %H:%M:%S")
> doesn't do it.
> ValueError: time data did not match format: data=2009/01/02 13:01:15
> fmt=%y/%m/%d %H:%
On Sun, Dec 27, 2009 at 8:54 PM, W. eWatson wrote:
> That's fine, but I'd like to start with two dates as strings, as
> "1961/06/16 04:35:25" and "1973/01/18 03:45:50"
>
> How do I get the strings into a shape that will accommodate a difference?
>
> For example,
> t1=datetime.datetime.strptime("2
According to one web source, this program:
import datetime
bree = datetime.datetime(1981, 6, 16, 4, 35, 25)
nat = datetime.datetime(1973, 1, 18, 3, 45, 50)
difference = bree - nat
print "There were", difference, "minutes between Nat and Bree"
yields:
There were 3071 days, 0:49:35 minutes betwe
thanks Robert, those 4 lines of code sure beat the 58 of my
home-rolled time-date function!
cheers
S
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 8 May 2005 19:06:31 -0600, Stewart Midwinter <[EMAIL PROTECTED]> wrote:
>After an hour of research, I'm more confused than ever. I don't know
>if I should use the time module, or the eGenix datetime module. Here's
>what I want to do: I want to calculate the time difference (in
>seconds wou
Stewart Midwinter wrote:
> After an hour of research, I'm more confused than ever. I don't know
> if I should use the time module, or the eGenix datetime module. Here's
> what I want to do: I want to calculate the time difference (in
> seconds would be okay, or minutes), between two date-time stri
After an hour of research, I'm more confused than ever. I don't know
if I should use the time module, or the eGenix datetime module. Here's
what I want to do: I want to calculate the time difference (in
seconds would be okay, or minutes), between two date-time strings.
so: something like this:
ti
35 matches
Mail list logo