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:
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)
type 'datetime.datetime'
t1: 2009-12-05 22:11:00 type 'datetime.datetime'
but in the program:
import datetime
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)
type 'datetime.datetime'
t1: 2009-12-05 22:11:00 type 'datetime.datetime'
but in the program:
import datetime
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)
type 'datetime.datetime'
t1: 2009-12-05 22:11:00 type 'datetime.datetime'
but in the program:
import datetime
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)
type 'datetime.datetime'
t1: 2009-12-05 22:11:00 type 'datetime.datetime'
but in the
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:
There were 3071
On Tue, Dec 29, 2009 at 7:21 AM, M.-A. Lemburg m...@egenix.com wrote:
If you want a more human readable, relative format use Age():
Age(bree, nat)
RelativeDateTime instance for '(+0008)-(+04)-(+29) HH:(+49):(+35)' at
0x2b99c6e37ef0
i.e. 8 years, 4 months, 29 days, 49 minutes, 35 seconds.
In article hh9dmv$f9...@news.eternal-september.org,
W. eWatson wolftra...@invalid.com 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
BTW, all times are local to my city. Same time zone.
--
http://mail.python.org/mailman/listinfo/python-list
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,
W. eWatson wolftra...@invalid.com 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
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
Roy Smith wrote:
In article hh9k6g$pk...@news.eternal-september.org,
W. eWatson wolftra...@invalid.com 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
On Mon, 28 Dec 2009 08:20:28 -0800
W. eWatson wolftra...@invalid.com 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
D'Arcy J.M. Cain wrote:
On Mon, 28 Dec 2009 08:20:28 -0800
W. eWatson wolftra...@invalid.com 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
Ben Finney wrote:
W. eWatson wolftra...@invalid.com 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
In article hh9k6g$pk...@news.eternal-september.org,
W. eWatson wolftra...@invalid.com 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
In article roy-2455bd.09122528122...@news.panix.com,
Roy Smith r...@panix.com 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
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
URL:http://docs.python.org/library/datetime.html#datetime.timedelta.
No no no, it's customary to annoy
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)
type 'datetime.datetime'
t1: 2009-12-05 22:11:00 type 'datetime.datetime'
but in the
On Mon, 28 Dec 2009 10:54:46 -0800, W. eWatson wrote:
Ben Finney wrote:
W. eWatson wolftra...@invalid.com 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
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
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 way of
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
URL:http://docs.python.org/library/datetime.html#datetime.timedelta.
No no no,
W. eWatson wolftra...@invalid.com 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
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 between
On Sun, Dec 27, 2009 at 8:54 PM, W. eWatson wolftra...@invalid.com 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,
W. eWatson wolftra...@invalid.com 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
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 guess.
Ben Finney wrote:
W. eWatson wolftra...@invalid.com 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
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,
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:
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
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 would be
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
35 matches
Mail list logo